cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
create t set a, b, c, d char(10,1);
insert into t values (
1, 1, 10, 'ten',
1, 2, 9, 'nine',
1, 1, 8, 'eight',
2, 1, 7, 'seven',
1, 2, 6, 'six',
2, 2, 5, 'five',
1, 1, 4, 'four',
3, 2, 3, 'three',
1, 1, 10, 'ten',
1, 2, 2, 'two');

create view v1 (a, b, c, sumc) as select a, b, c, sum (c) from t group by a, b;
select from v1;

create view v2 (a, b, sumc) as select a, b, sum (c) from t group by a, b;
select from v2;

create view v3 (a, b, c, sumc, sumdistc) as select a, b, c, sum (c),
	sum (distinct c) from t group by a, b;
select from v3;

create view v4 (a, b, d, lend, sumlend, sumdistlend) as select a, b, d, length (d),
	sum (length (d)), sum (distinct length (d)) from t group by a, b;
select from v4;

create view v5 (a, b, c, minc, maxc, sumc, avgc) as select a, b, c, min (c),
	max (c), sum (c), avg (c) from t group by a, b;
select from v5;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c, d char(10,1);
* insert into t values (
. 1, 1, 10, 'ten',
. 1, 2, 9, 'nine',
. 1, 1, 8, 'eight',
. 2, 1, 7, 'seven',
. 1, 2, 6, 'six',
. 2, 2, 5, 'five',
. 1, 1, 4, 'four',
. 3, 2, 3, 'three',
. 1, 1, 10, 'ten',
. 1, 2, 2, 'two');
* 
* create view v1 (a, b, c, sumc) as select a, b, c, sum (c) from t group by a, b;
* select from v1;
     a       b       c         sumc

     1       1      10
     1       2       9
     1       1       8
     2       1       7
     1       2       6
     2       2       5
     1       1       4
     3       2       3
     1       1      10
     1       2       2
     1       1                   32
     1       2                   17
     2       2                    5
     3       2                    3
     2       1                    7
* 
* create view v2 (a, b, sumc) as select a, b, sum (c) from t group by a, b;
* select from v2;
     a       b         sumc

     1       1           32
     1       2           17
     2       2            5
     3       2            3
     2       1            7
* 
* create view v3 (a, b, c, sumc, sumdistc) as select a, b, c, sum (c),
. 	sum (distinct c) from t group by a, b;
* select from v3;
     a       b       c         sumc     sumdistc

     1       1      10
     1       2       9
     1       1       8
     2       1       7
     1       2       6
     2       2       5
     1       1       4
     3       2       3
     1       1      10
     1       2       2
     1       1                   32           22
     1       2                   17           17
     2       2                    5            5
     3       2                    3            3
     2       1                    7            7
* 
* create view v4 (a, b, d, lend, sumlend, sumdistlend) as select a, b, d, length (d),
. 	sum (length (d)), sum (distinct length (d)) from t group by a, b;
* select from v4;
     a       b  d                  lend      sumlend  sumdistlend

     1       1  ten                   3
     1       2  nine                  4
     1       1  eight                 5
     2       1  seven                 5
     1       2  six                   3
     2       2  five                  4
     1       1  four                  4
     3       2  three                 5
     1       1  ten                   3
     1       2  two                   3
     1       1                                    15           12
     1       2                                    10            7
     2       2                                     4            4
     3       2                                     5            5
     2       1                                     5            5
* 
* create view v5 (a, b, c, minc, maxc, sumc, avgc) as select a, b, c, min (c),
. 	max (c), sum (c), avg (c) from t group by a, b;
* select from v5;
     a       b       c         minc         maxc         sumc                      avgc

     1       1      10
     1       2       9
     1       1       8
     2       1       7
     1       2       6
     2       2       5
     1       1       4
     3       2       3
     1       1      10
     1       2       2
     1       1                    4           10           32                      8.00
     1       2                    2            9           17                      5.67
     2       2                    5            5            5                      5.00
     3       2                    3            3            3                      3.00
     2       1                    7            7            7                      7.00
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
More test for the new group by.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
