ClickHouse/tests/queries/0_stateless/02293_grouping_function.sql

102 lines
1.7 KiB
MySQL
Raw Normal View History

2022-05-12 16:39:50 +00:00
SELECT
number,
grouping(number, number % 2, number % 3) AS gr
FROM numbers(10)
2022-05-18 15:23:31 +00:00
GROUP BY
GROUPING SETS (
(number),
(number % 2)
)
ORDER BY number, gr; -- { serverError BAD_ARGUMENTS }
-- { echoOn }
2022-05-18 15:23:31 +00:00
SELECT
number,
grouping(number, number % 2) AS gr
FROM numbers(10)
2022-05-12 16:39:50 +00:00
GROUP BY
GROUPING SETS (
(number),
(number % 2)
)
ORDER BY number, gr;
SELECT
number,
2022-05-18 15:23:31 +00:00
grouping(number % 2, number) AS gr
2022-05-12 16:39:50 +00:00
FROM numbers(10)
GROUP BY
GROUPING SETS (
(number),
(number % 2)
)
ORDER BY number, gr;
SELECT
number,
2022-05-18 15:23:31 +00:00
grouping(number, number % 2) = 1 AS gr
2022-05-12 16:39:50 +00:00
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)
)
2022-05-18 15:23:31 +00:00
ORDER BY number, grouping(number, number % 2) = 1;
2022-05-12 16:39:50 +00:00
SELECT
number,
count(),
2022-05-18 15:23:31 +00:00
grouping(number, number % 2) AS gr
2022-05-12 16:39:50 +00:00
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)
)
2022-05-18 15:23:31 +00:00
HAVING grouping(number, number % 2) = 2
2022-05-12 16:39:50 +00:00
ORDER BY number
SETTINGS enable_optimize_predicate_expression = 0;
SELECT
number
FROM numbers(10)
GROUP BY
GROUPING SETS (
(number),
(number % 2)
)
2022-05-18 15:23:31 +00:00
HAVING grouping(number, number % 2) = 1
2022-05-12 16:39:50 +00:00
ORDER BY number
SETTINGS enable_optimize_predicate_expression = 0;
SELECT
number,
2022-05-18 15:23:31 +00:00
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;