CREATE TABLE distinct_cardinality (high UInt64, middle UInt64, low UInt64) ENGINE MergeTree() ORDER BY (high, middle, low)
INSERT INTO distinct_cardinality SELECT number, number % 1000, number % 10 from numbers(1000000)
select distinct high from distinct_cardinality
select distinct high, low from distinct_cardinality
select distinct high, middle from distinct_cardinality
select distinct high, middle, low from distinct_cardinality
select distinct high, middle from distinct_cardinality order by middle
select distinct high, low from distinct_cardinality order by low
select distinct high, middle, low from distinct_cardinality order by high
DROP TABLE IF EXISTS distinct_cardinality