mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 05:52:05 +00:00
240 lines
2.7 KiB
Plaintext
240 lines
2.7 KiB
Plaintext
-- { echoOn }
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY ROLLUP(number, number % 2)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=1;
|
|
0 0 0
|
|
0 \N 0
|
|
1 1 1
|
|
1 \N 1
|
|
2 0 2
|
|
2 \N 2
|
|
3 1 3
|
|
3 \N 3
|
|
4 0 4
|
|
4 \N 4
|
|
5 1 5
|
|
5 \N 5
|
|
6 0 6
|
|
6 \N 6
|
|
7 1 7
|
|
7 \N 7
|
|
8 0 8
|
|
8 \N 8
|
|
9 1 9
|
|
9 \N 9
|
|
\N \N 45
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY ROLLUP(number, number % 2)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=0;
|
|
0 0 0
|
|
0 0 0
|
|
0 0 45
|
|
1 0 1
|
|
1 1 1
|
|
2 0 2
|
|
2 0 2
|
|
3 0 3
|
|
3 1 3
|
|
4 0 4
|
|
4 0 4
|
|
5 0 5
|
|
5 1 5
|
|
6 0 6
|
|
6 0 6
|
|
7 0 7
|
|
7 1 7
|
|
8 0 8
|
|
8 0 8
|
|
9 0 9
|
|
9 1 9
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY CUBE(number, number % 2)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=1;
|
|
0 0 0
|
|
0 \N 0
|
|
1 1 1
|
|
1 \N 1
|
|
2 0 2
|
|
2 \N 2
|
|
3 1 3
|
|
3 \N 3
|
|
4 0 4
|
|
4 \N 4
|
|
5 1 5
|
|
5 \N 5
|
|
6 0 6
|
|
6 \N 6
|
|
7 1 7
|
|
7 \N 7
|
|
8 0 8
|
|
8 \N 8
|
|
9 1 9
|
|
9 \N 9
|
|
\N 0 20
|
|
\N 1 25
|
|
\N \N 45
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY CUBE(number, number % 2)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=0;
|
|
0 0 0
|
|
0 0 0
|
|
0 0 20
|
|
0 0 45
|
|
0 1 25
|
|
1 0 1
|
|
1 1 1
|
|
2 0 2
|
|
2 0 2
|
|
3 0 3
|
|
3 1 3
|
|
4 0 4
|
|
4 0 4
|
|
5 0 5
|
|
5 1 5
|
|
6 0 6
|
|
6 0 6
|
|
7 0 7
|
|
7 1 7
|
|
8 0 8
|
|
8 0 8
|
|
9 0 9
|
|
9 1 9
|
|
SELECT
|
|
number,
|
|
number % 2,
|
|
sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls = 1;
|
|
0 \N 0
|
|
1 \N 1
|
|
2 \N 2
|
|
3 \N 3
|
|
4 \N 4
|
|
5 \N 5
|
|
6 \N 6
|
|
7 \N 7
|
|
8 \N 8
|
|
9 \N 9
|
|
\N 0 20
|
|
\N 1 25
|
|
SELECT
|
|
number,
|
|
number % 2,
|
|
sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls = 0;
|
|
0 0 0
|
|
0 0 20
|
|
0 1 25
|
|
1 0 1
|
|
2 0 2
|
|
3 0 3
|
|
4 0 4
|
|
5 0 5
|
|
6 0 6
|
|
7 0 7
|
|
8 0 8
|
|
9 0 9
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY ROLLUP(number, number % 2) WITH TOTALS
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=1;
|
|
0 0 0
|
|
0 \N 0
|
|
1 1 1
|
|
1 \N 1
|
|
2 0 2
|
|
2 \N 2
|
|
3 1 3
|
|
3 \N 3
|
|
4 0 4
|
|
4 \N 4
|
|
5 1 5
|
|
5 \N 5
|
|
6 0 6
|
|
6 \N 6
|
|
7 1 7
|
|
7 \N 7
|
|
8 0 8
|
|
8 \N 8
|
|
9 1 9
|
|
9 \N 9
|
|
\N \N 45
|
|
|
|
0 0 45
|
|
SELECT number, number % 2, sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY CUBE(number, number % 2) WITH TOTALS
|
|
ORDER BY (number, number % 2, val)
|
|
SETTINGS group_by_use_nulls=1;
|
|
0 0 0
|
|
0 \N 0
|
|
1 1 1
|
|
1 \N 1
|
|
2 0 2
|
|
2 \N 2
|
|
3 1 3
|
|
3 \N 3
|
|
4 0 4
|
|
4 \N 4
|
|
5 1 5
|
|
5 \N 5
|
|
6 0 6
|
|
6 \N 6
|
|
7 1 7
|
|
7 \N 7
|
|
8 0 8
|
|
8 \N 8
|
|
9 1 9
|
|
9 \N 9
|
|
\N 0 20
|
|
\N 1 25
|
|
\N \N 45
|
|
|
|
0 0 45
|
|
SELECT
|
|
number,
|
|
number % 2,
|
|
sum(number) AS val
|
|
FROM numbers(10)
|
|
GROUP BY
|
|
GROUPING SETS (
|
|
(number),
|
|
(number % 2)
|
|
)
|
|
ORDER BY 1, tuple(val)
|
|
SETTINGS group_by_use_nulls = 1, max_bytes_before_external_sort=10;
|
|
0 \N 0
|
|
1 \N 1
|
|
2 \N 2
|
|
3 \N 3
|
|
4 \N 4
|
|
5 \N 5
|
|
6 \N 6
|
|
7 \N 7
|
|
8 \N 8
|
|
9 \N 9
|
|
\N 0 20
|
|
\N 1 25
|