1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-27 08:21:15 +03:00
Files
mariadb-columnstore-engine/mtr/basic/r/mcs136_window_function_sum.result
mariadb-RomanNavrotskiy 73b4147cf3 move mtr suites here
2021-01-31 01:38:31 +02:00

128 lines
2.1 KiB
Plaintext

DROP DATABASE IF EXISTS mcs136_db;
CREATE DATABASE mcs136_db;
USE mcs136_db;
CREATE TABLE t1 (a CHAR(1), b INT)ENGINE=Columnstore;
INSERT INTO t1 VALUES ('', NULL),('a', 123),('a', 1),('b', 123),('c', 1861),('c', 1991),('d', 10701),('d', 1071),('a', 92);
SELECT a, b, SUM(b) OVER(ORDER BY a) sum FROM t1;
a b sum
NULL NULL NULL
a 92 216
a 1 216
a 123 216
b 123 339
c 1991 4191
c 1861 4191
d 1071 15963
d 10701 15963
SELECT a, b, SUM(b) OVER(ORDER BY b DESC) sum FROM t1;
a b sum
d 10701 10701
c 1991 12692
c 1861 14553
d 1071 15624
a 123 15870
b 123 15870
a 92 15962
a 1 15963
NULL NULL 15963
SELECT a, b, SUM(b) OVER w sum FROM t1 WINDOW w AS (ORDER BY a DESC);
a b sum
d 10701 11772
d 1071 11772
c 1861 15624
c 1991 15624
b 123 15747
a 92 15963
a 123 15963
a 1 15963
NULL NULL 15963
SELECT a, b, SUM(b) OVER w sum FROM t1 WINDOW w AS (ORDER BY b);
a b sum
NULL NULL NULL
a 1 1
a 92 93
b 123 339
a 123 339
d 1071 1410
c 1861 3271
c 1991 5262
d 10701 15963
SELECT a, b, SUM(b) OVER(PARTITION BY a) sum FROM t1;
a b sum
NULL NULL NULL
a 92 216
a 1 216
a 123 216
b 123 123
c 1991 3852
c 1861 3852
d 1071 11772
d 10701 11772
SELECT a, b, SUM(b) OVER(PARTITION BY b) sum FROM t1;
a b sum
NULL NULL NULL
a 1 1
a 92 92
b 123 246
a 123 246
d 1071 1071
c 1861 1861
c 1991 1991
d 10701 10701
SELECT a, b, SUM(b) OVER(PARTITION BY a ORDER BY a DESC) sum FROM t1;
a b sum
NULL NULL NULL
a 92 216
a 1 216
a 123 216
b 123 123
c 1991 3852
c 1861 3852
d 1071 11772
d 10701 11772
SELECT a, b, SUM(b) OVER(PARTITION BY a ORDER BY b DESC) sum FROM t1;
a b sum
NULL NULL NULL
a 123 123
a 92 215
a 1 216
b 123 123
c 1991 1991
c 1861 3852
d 10701 10701
d 1071 11772
SELECT a, b, SUM(b) OVER(PARTITION BY a ORDER BY b ASC) sum FROM t1;
a b sum
NULL NULL NULL
a 1 1
a 92 93
a 123 216
b 123 123
c 1861 1861
c 1991 3852
d 1071 1071
d 10701 11772
SELECT a, b, SUM(b) OVER(PARTITION BY b ORDER BY a DESC) sum FROM t1;
a b sum
NULL NULL NULL
a 1 1
a 92 92
b 123 123
a 123 246
d 1071 1071
c 1861 1861
c 1991 1991
d 10701 10701
SELECT a, b, SUM(b) OVER(PARTITION BY b ORDER BY b DESC) sum FROM t1;
a b sum
NULL NULL NULL
a 1 1
a 92 92
b 123 246
a 123 246
d 1071 1071
c 1861 1861
c 1991 1991
d 10701 10701
DROP DATABASE mcs136_db;