ClickHouse/tests/queries/0_stateless/00453_top_k.sql
2020-12-12 15:08:46 +03:00

16 lines
358 B
SQL

SELECT topK(10)(n) FROM (SELECT if(number % 100 < 10, number % 10, number) AS n FROM system.numbers LIMIT 100000);
SELECT
k,
topK(v)
FROM
(
SELECT
number % 7 AS k,
arrayMap(x -> arrayMap(x -> if(x = 0, NULL, toString(x)), range(x)), range(intDiv(number, 1))) AS v
FROM system.numbers
LIMIT 10
)
GROUP BY k
ORDER BY k ASC