mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-20 06:32:08 +00:00
183 lines
2.2 KiB
Plaintext
183 lines
2.2 KiB
Plaintext
-- { echoOn }
|
|
SELECT
|
|
number,
|
|
grouping(number, number % 2) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0 1
|
|
0 1
|
|
0 2
|
|
1 2
|
|
2 2
|
|
3 2
|
|
4 2
|
|
5 2
|
|
6 2
|
|
7 2
|
|
8 2
|
|
9 2
|
|
SELECT
|
|
number,
|
|
grouping(number % 2, number) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0 1
|
|
0 2
|
|
0 2
|
|
1 1
|
|
2 1
|
|
3 1
|
|
4 1
|
|
5 1
|
|
6 1
|
|
7 1
|
|
8 1
|
|
9 1
|
|
SELECT
|
|
number,
|
|
grouping(number, number % 2) = 1 AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, gr
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0 0
|
|
0 1
|
|
0 1
|
|
1 0
|
|
2 0
|
|
3 0
|
|
4 0
|
|
5 0
|
|
6 0
|
|
7 0
|
|
8 0
|
|
9 0
|
|
SELECT
|
|
number
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY number, grouping(number, number % 2) = 1
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0
|
|
0
|
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
SELECT
|
|
number,
|
|
count(),
|
|
grouping(number, number % 2) AS gr
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number, number % 2),
|
|
()
|
|
)
|
|
ORDER BY (gr, number)
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0 10 0
|
|
0 1 2
|
|
1 1 2
|
|
2 1 2
|
|
3 1 2
|
|
4 1 2
|
|
5 1 2
|
|
6 1 2
|
|
7 1 2
|
|
8 1 2
|
|
9 1 2
|
|
0 1 3
|
|
1 1 3
|
|
2 1 3
|
|
3 1 3
|
|
4 1 3
|
|
5 1 3
|
|
6 1 3
|
|
7 1 3
|
|
8 1 3
|
|
9 1 3
|
|
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, force_grouping_standard_compatibility=0;
|
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
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, force_grouping_standard_compatibility=0;
|
|
0
|
|
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
|
|
SETTINGS force_grouping_standard_compatibility=0;
|
|
0 0
|
|
0 1
|
|
0 1
|
|
1 0
|
|
2 0
|
|
3 0
|
|
4 0
|
|
5 0
|
|
6 0
|
|
7 0
|
|
8 0
|
|
9 0
|