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/mcs140_window_function_median.result
mariadb-RomanNavrotskiy 73b4147cf3 move mtr suites here
2021-01-31 01:38:31 +02:00

35 lines
1.3 KiB
Plaintext

DROP DATABASE IF EXISTS mcs140_db;
CREATE DATABASE mcs140_db;
USE mcs140_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, MEDIAN(b) OVER(PARTITION BY b) median FROM t1;
a b median
NULL NULL NULL
a 1 1.0000000000
a 92 92.0000000000
b 123 123.0000000000
a 123 123.0000000000
d 1071 1071.0000000000
c 1861 1861.0000000000
c 1991 1991.0000000000
d 10701 10701.0000000000
SELECT a, b, MEDIAN(b) OVER(PARTITION BY a) median FROM t1;
a b median
NULL NULL NULL
a 123 92.0000000000
a 92 92.0000000000
a 1 92.0000000000
b 123 123.0000000000
c 1991 1926.0000000000
c 1861 1926.0000000000
d 10701 5886.0000000000
d 1071 5886.0000000000
SELECT a, b, MEDIAN(b) OVER(ORDER BY b DESC) median FROM t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY b DESC) median FROM t1' at line 1
SELECT a, b, MEDIAN(a) OVER(PARTITION BY a) median FROM t1;
ERROR HY000: Numeric datatype is required for percentile_cont function
SELECT a, b, MEDIAN(a) OVER(PARTITION BY b) median FROM t1;
ERROR HY000: Numeric datatype is required for percentile_cont function
DROP DATABASE mcs140_db;