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-09-17 19:16:51 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO rollup VALUES('a', 1, 10);
|
|
|
|
INSERT INTO rollup VALUES('a', 1, 15);
|
|
|
|
INSERT INTO rollup VALUES('a', 2, 20);
|
|
|
|
INSERT INTO rollup VALUES('a', 2, 25);
|
|
|
|
INSERT INTO rollup VALUES('b', 1, 10);
|
|
|
|
INSERT INTO rollup VALUES('b', 1, 5);
|
|
|
|
INSERT INTO rollup VALUES('b', 2, 20);
|
|
|
|
INSERT INTO rollup VALUES('b', 2, 15);
|
2018-09-17 19:16:51 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY CUBE(a, b) ORDER BY a, b;
|
2018-09-17 19:16:51 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY CUBE(a, b) WITH TOTALS ORDER BY a, b;
|
2018-09-17 19:16:51 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY a, b WITH CUBE ORDER BY a;
|
2018-09-19 11:18:38 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT a, b, sum(s), count() from rollup GROUP BY a, b WITH CUBE WITH TOTALS ORDER BY a;
|
2019-06-07 14:59:41 +00:00
|
|
|
|
|
|
|
DROP TABLE rollup;
|