mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
16 lines
358 B
SQL
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
|