statement ok CREATE TABLE test (id int primary key, x int, y int); statement ok INSERT INTO test VALUES (0, 1, 1), (1, 2, 2), (2, 1, 1), (3, 3, 3); query II rowsort SELECT DISTINCT x FROM test; ---- 1 2 3 query II SELECT DISTINCT x FROM test ORDER BY x, id; ---- 1 2 3 query I SELECT DISTINCT sum(x) FROM test ORDER BY sum(x); ---- 7 # ORDER BY items must appear in the select list # if SELECT DISTINCT is specified statement error SELECT DISTINCT x FROM test ORDER BY y;