QUERY: create table s1 (x int4, y int4);
QUERY: create table s2 (a int4, b int4, c int4);
QUERY: insert into s1 values (1, 3);
QUERY: insert into s1 values (2, 3);
QUERY: insert into s1 values (2, 1);
QUERY: insert into s2 values (1, 3, 9);
QUERY: insert into s2 values (1, 4, 9);
QUERY: insert into s2 values (3, 4, 7);
QUERY: insert into s2 values (3, 5, 8);
QUERY: select distinct y from s1;
y  
-- 
1  
3  
QUERY: select a, c from s2;
a  c  
-- -- 
1  9  
1  9  
3  7  
3  8  
QUERY: select distinct a, c from s2;
a  c  
-- -- 
1  9  
3  7  
3  8  
QUERY: select distinct a, c from s2 order by c;
a  c  
-- -- 
3  7  
3  8  
1  9  
QUERY: select b, c from s2 order by c, b;
b  c  
-- -- 
4  7  
5  8  
3  9  
4  9  
QUERY: select x, b, c from s1, s2 order by b;
x  b  c  
-- -- -- 
2  3  9  
2  3  9  
1  3  9  
2  4  7  
2  4  7  
1  4  7  
2  4  9  
2  4  9  
1  4  9  
2  5  8  
2  5  8  
1  5  8  
QUERY: select distinct a, x, c from s1, s2 order by c, x;
a  x  c  
-- -- -- 
3  1  7  
3  2  7  
3  1  8  
3  2  8  
1  1  9  
1  2  9  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p;
p  q  r  
-- -- -- 
1  5  8  
1  4  7  
1  4  9  
1  3  9  
2  3  9  
2  3  9  
2  5  8  
2  5  8  
2  4  9  
2  4  7  
2  4  9  
2  4  7  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q;
p  q  r  
-- -- -- 
2  3  9  
2  3  9  
1  3  9  
2  4  7  
2  4  7  
1  4  7  
2  4  9  
2  4  9  
1  4  9  
2  5  8  
2  5  8  
1  5  8  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by r;
p  q  r  
-- -- -- 
2  4  7  
2  4  7  
1  4  7  
2  5  8  
2  5  8  
1  5  8  
2  4  9  
2  4  9  
1  4  9  
2  3  9  
2  3  9  
1  3  9  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p, r;
p  q  r  
-- -- -- 
1  4  7  
1  5  8  
1  4  9  
1  3  9  
2  4  7  
2  4  7  
2  5  8  
2  5  8  
2  3  9  
2  4  9  
2  3  9  
2  4  9  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, r;
p  q  r  
-- -- -- 
2  3  9  
2  3  9  
1  3  9  
2  4  7  
2  4  7  
1  4  7  
2  4  9  
2  4  9  
1  4  9  
2  5  8  
2  5  8  
1  5  8  
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, p;
p  q  r  
-- -- -- 
1  3  9  
2  3  9  
2  3  9  
1  4  9  
1  4  7  
2  4  7  
2  4  7  
2  4  9  
2  4  9  
1  5  8  
2  5  8  
2  5  8  
QUERY: create table s3 (x int4);
QUERY: insert into s3 values (3);
QUERY: insert into s3 values (4);
QUERY: select * from s1, s3 order by x;
x  y  x  
-- -- -- 
1  3  4  
1  3  3  
2  1  3  
2  3  3  
2  1  4  
2  3  4  
QUERY: select * from s3, s1 order by x;
x  x  y  
-- -- -- 
3  2  1  
3  2  3  
3  1  3  
4  2  3  
4  1  3  
4  2  1  
QUERY: create table s4 (a int4, b int4, c int4, d int4, e int4, f int4, g int4, h int4, i int4);
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 2);
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 1);
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 3);
QUERY: select * from s4 order by a, b, c, d, e, f, g, h;
a  b  c  d  e  f  g  h  i  
-- -- -- -- -- -- -- -- -- 
1  1  1  1  1  1  1  1  3  
1  1  1  1  1  1  1  1  1  
1  1  1  1  1  1  1  1  2  
QUERY: create table s5 (a int4, b int4);
QUERY: insert into s5 values (1, 2);
QUERY: insert into s5 values (1, 3);
QUERY: insert into s5 values (1, 1);
QUERY: insert into s5 values (2, 1);
QUERY: insert into s5 values (2, 4);
QUERY: insert into s5 values (2, 2);
QUERY: select * from s5 order by a using <;
a  b  
-- -- 
1  1  
1  3  
1  2  
2  2  
2  4  
2  1  
QUERY: select * from s5 order by a using >;
a  b  
-- -- 
2  2  
2  4  
2  1  
1  1  
1  3  
1  2  
QUERY: select * from s5 order by a using >, b using <;
a  b  
-- -- 
2  1  
2  2  
2  4  
1  1  
1  2  
1  3  
QUERY: select * from s5 order by a using >, b using >;
a  b  
-- -- 
2  4  
2  2  
2  1  
1  3  
1  2  
1  1  
QUERY: drop table s1, s2, s3, s4, s5;
