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

#ORDER BY references `id` which is not in the SELECT DISTINCT list, invalid in standard SQL.
statement error
SELECT DISTINCT x FROM test ORDER BY x, id;

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;