mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 05:52:05 +00:00
102 lines
1.7 KiB
SQL
102 lines
1.7 KiB
SQL
SELECT
|
|
number,
|
|
grouping(number, number % 2, number % 3) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr; -- { serverError BAD_ARGUMENTS }
|
|
|
|
-- { echoOn }
|
|
SELECT
|
|
number,
|
|
grouping(number, number % 2) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr;
|
|
|
|
SELECT
|
|
number,
|
|
grouping(number % 2, number) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr;
|
|
|
|
SELECT
|
|
number,
|
|
grouping(number, number % 2) = 1 AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr;
|
|
|
|
SELECT
|
|
number
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, grouping(number, number % 2) = 1;
|
|
|
|
SELECT
|
|
number,
|
|
count(),
|
|
grouping(number, number % 2) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number, number % 2),
|
|
()
|
|
)
|
|
ORDER BY (gr, number);
|
|
|
|
SELECT
|
|
number
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
HAVING grouping(number, number % 2) = 2
|
|
ORDER BY number
|
|
SETTINGS enable_optimize_predicate_expression = 0;
|
|
|
|
SELECT
|
|
number
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
HAVING grouping(number, number % 2) = 1
|
|
ORDER BY number
|
|
SETTINGS enable_optimize_predicate_expression = 0;
|
|
|
|
SELECT
|
|
number,
|
|
GROUPING(number, number % 2) = 1 as gr
|
|
FROM remote('127.0.0.{2,3}', numbers(10))
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2))
|
|
ORDER BY number, gr;
|