2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-parallel, no-fasttest
|
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS rollup;
|
|
|
|
CREATE TABLE rollup(a String, b Int32, s Int32) ENGINE = Memory;
|
2018-08-24 17:34:56 +00:00
|
|
|
|
2019-07-30 16:36:52 +00:00
|
|
|
INSERT INTO rollup VALUES ('a', 1, 10), ('a', 1, 15), ('a', 2, 20);
|
|
|
|
INSERT INTO rollup VALUES ('a', 2, 25), ('b', 1, 10), ('b', 1, 5);
|
|
|
|
INSERT INTO rollup VALUES ('b', 2, 20), ('b', 2, 15);
|
2018-08-24 17:34:56 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY ROLLUP(a, b) ORDER BY a, b;
|
2018-08-24 17:34:56 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY ROLLUP(a, b) WITH TOTALS ORDER BY a, b;
|
2018-08-24 17:34:56 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, sum(s), count() from rollup GROUP BY ROLLUP(a) ORDER BY a;
|
2018-08-27 16:43:29 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, sum(s), count() from rollup GROUP BY a WITH ROLLUP ORDER BY a;
|
2018-08-27 16:43:29 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, sum(s), count() from rollup GROUP BY a WITH ROLLUP WITH TOTALS ORDER BY a;
|
2019-06-07 15:41:24 +00:00
|
|
|
|
2019-07-30 16:36:52 +00:00
|
|
|
SET group_by_two_level_threshold = 1;
|
|
|
|
|
|
|
|
SELECT a, sum(s), count() from rollup GROUP BY a WITH ROLLUP ORDER BY a;
|
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY a, b WITH ROLLUP ORDER BY a, b;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE rollup;
|