cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
create t set a, b, c, d;
insert into t values (
1, 1, 10, 101,
1, 2, 9, 102,
1, 1, 8, 103,
2, 1, 7, 104,
1, 2, 6, 105,
2, 2, 5, 106,
1, 1, 4, 107,
3, 2, 3, 108,
1, 2, 2, 109);

create view v1 as select a, b from t order by a, b;
select from v1;
create view v2 as select a, b from t group by a, b;
select from v2;
create view v3 as select a, b from t group by a, b order by a, b;
select from v3;
create view v4 as select a, b from t group by a, b order by a desc, b desc;
select from v4;
create view v5 as select a, b from t group by a, b order by b, a;
select from v5;
create view v6 as select a, b from t group by a, b order by b desc, a desc;
select from v6;
create view v7 as select a, b from t group by a, b, c order by a, b;
select from v7;
create view v8 as select a, b from t group by a, b, c order by a desc, b desc;
select from v8;
create view v9 as select a, b from t group by a, b order by a, b;
select from v9;
create view v10 as select a, b from t group by a, b order by a desc, b desc;
select from v10;
create view v11 as select a, b from t group by a, b, c order by a, b;
select from v11;
create view v12 as select a, b from t group by a, b, c order by a desc, b desc;
select from v12;


create view v13 as select a, b, c from t order by a, b;
select from v13;
create view v14 as select a, b, c from t group by a, b;
select from v14;
create view v15 as select a, b, c from t group by a, b order by a, b;
select from v15;
create view v16 as select a, b, c from t group by a, b order by a desc, b desc;
select from v16;
create view v17 as select a, b, c from t group by a, b order by b, a;
select from v17;
create view v18 as select a, b, c from t group by a, b order by b desc, a desc;
select from v18;
create view v19 as select a, b, c from t group by a, b, c order by a, b;
select from v19;
create view v20 as select a, b, c from t group by a, b, c order by a desc, b desc;
select from v20;
create view v21 as select a, b, c from t group by a, b order by a, b, c;
select from v21;
create view v22 as select a, b, c from t group by a, b order by a, b desc, c desc;
select from v22;
create view  v23 as select a, b, c from t group by a, b, c order by a, b, c;
select from v23;
create view v24 as select a, b, c from t group by a, b, c order by a desc, b desc, c desc;
select from v24;
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* create t set a, b, c, d;
* insert into t values (
. 1, 1, 10, 101,
. 1, 2, 9, 102,
. 1, 1, 8, 103,
. 2, 1, 7, 104,
. 1, 2, 6, 105,
. 2, 2, 5, 106,
. 1, 1, 4, 107,
. 3, 2, 3, 108,
. 1, 2, 2, 109);
* 
* create view v1 as select a, b from t order by a, b;
* select from v1;
     a       b

     1       1
     1       1
     1       1
     1       2
     1       2
     1       2
     2       1
     2       2
     3       2
* create view v2 as select a, b from t group by a, b;
* select from v2;
     a       b

     1       1
     1       2
     2       2
     3       2
     2       1
* create view v3 as select a, b from t group by a, b order by a, b;
* select from v3;
     a       b

     1       1
     1       2
     2       1
     2       2
     3       2
* create view v4 as select a, b from t group by a, b order by a desc, b desc;
* select from v4;
     a       b

     3       2
     2       2
     2       1
     1       2
     1       1
* create view v5 as select a, b from t group by a, b order by b, a;
* select from v5;
     a       b

     1       1
     2       1
     1       2
     2       2
     3       2
* create view v6 as select a, b from t group by a, b order by b desc, a desc;
* select from v6;
     a       b

     3       2
     2       2
     1       2
     2       1
     1       1
* create view v7 as select a, b from t group by a, b, c order by a, b;
* select from v7;
     a       b

     1       1
     1       1
     1       1
     1       2
     1       2
     1       2
     2       1
     2       2
     3       2
* create view v8 as select a, b from t group by a, b, c order by a desc, b desc;
* select from v8;
     a       b

     3       2
     2       2
     2       1
     1       2
     1       2
     1       2
     1       1
     1       1
     1       1
* create view v9 as select a, b from t group by a, b order by a, b;
* select from v9;
     a       b

     1       1
     1       2
     2       1
     2       2
     3       2
* create view v10 as select a, b from t group by a, b order by a desc, b desc;
* select from v10;
     a       b

     3       2
     2       2
     2       1
     1       2
     1       1
* create view v11 as select a, b from t group by a, b, c order by a, b;
* select from v11;
     a       b

     1       1
     1       1
     1       1
     1       2
     1       2
     1       2
     2       1
     2       2
     3       2
* create view v12 as select a, b from t group by a, b, c order by a desc, b desc;
* select from v12;
     a       b

     3       2
     2       2
     2       1
     1       2
     1       2
     1       2
     1       1
     1       1
     1       1
* 
* 
* create view v13 as select a, b, c from t order by a, b;
* select from v13;
     a       b       c

     1       1      10
     1       1       8
     1       1       4
     1       2       9
     1       2       6
     1       2       2
     2       1       7
     2       2       5
     3       2       3
* create view v14 as select a, b, c from t group by a, b;
* select from v14;
     a       b       c

     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       2       2
     1       1
     1       2
     2       2
     3       2
     2       1
* create view v15 as select a, b, c from t group by a, b order by a, b;
* select from v15;
     a       b       c

     1       1      10
     1       1       8
     1       1       4
     1       1
     1       2       9
     1       2       6
     1       2       2
     1       2
     2       1       7
     2       1
     2       2       5
     2       2
     3       2       3
     3       2
* create view v16 as select a, b, c from t group by a, b order by a desc, b desc;
* select from v16;
     a       b       c

     3       2       3
     3       2
     2       2       5
     2       2
     2       1       7
     2       1
     1       2       9
     1       2       6
     1       2       2
     1       2
     1       1      10
     1       1       8
     1       1       4
     1       1
* create view v17 as select a, b, c from t group by a, b order by b, a;
* select from v17;
     a       b       c

     1       1      10
     1       1       8
     1       1       4
     1       1
     2       1       7
     2       1
     1       2       9
     1       2       6
     1       2       2
     1       2
     2       2       5
     2       2
     3       2       3
     3       2
* create view v18 as select a, b, c from t group by a, b order by b desc, a desc;
* select from v18;
     a       b       c

     3       2       3
     3       2
     2       2       5
     2       2
     1       2       9
     1       2       6
     1       2       2
     1       2
     2       1       7
     2       1
     1       1      10
     1       1       8
     1       1       4
     1       1
* create view v19 as select a, b, c from t group by a, b, c order by a, b;
* select from v19;
     a       b       c

     1       1       4
     1       1       8
     1       1      10
     1       2       9
     1       2       2
     1       2       6
     2       1       7
     2       2       5
     3       2       3
* create view v20 as select a, b, c from t group by a, b, c order by a desc, b desc;
* select from v20;
     a       b       c

     3       2       3
     2       2       5
     2       1       7
     1       2       9
     1       2       2
     1       2       6
     1       1       4
     1       1       8
     1       1      10
* create view v21 as select a, b, c from t group by a, b order by a, b, c;
* select from v21;
     a       b       c

     1       1
     1       1       4
     1       1       8
     1       1      10
     1       2
     1       2       2
     1       2       6
     1       2       9
     2       1
     2       1       7
     2       2
     2       2       5
     3       2
     3       2       3
* create view v22 as select a, b, c from t group by a, b order by a, b desc, c desc;
* select from v22;
     a       b       c

     1       2       9
     1       2       6
     1       2       2
     1       2
     1       1      10
     1       1       8
     1       1       4
     1       1
     2       2       5
     2       2
     2       1       7
     2       1
     3       2       3
     3       2
* create view  v23 as select a, b, c from t group by a, b, c order by a, b, c;
* select from v23;
     a       b       c

     1       1       4
     1       1       8
     1       1      10
     1       2       2
     1       2       6
     1       2       9
     2       1       7
     2       2       5
     3       2       3
* create view v24 as select a, b, c from t group by a, b, c order by a desc, b desc, c desc;
* select from v24;
     a       b       c

     3       2       3
     2       2       5
     2       1       7
     1       2       9
     1       2       6
     1       2       2
     1       1      10
     1       1       8
     1       1       4
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Test combinations of group by and order by.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
