Created
January 11, 2018 04:03
-
-
Save paul78oz/4ea9f626ae10333a5abaacf828804f94 to your computer and use it in GitHub Desktop.
Test of MariaDB 10.3.3 median() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE book_rating (id TINYINT, name CHAR(30), star_rating TINYINT); | |
INSERT INTO book_rating VALUES (1, 'Lord of the Ladybirds', 5); | |
INSERT INTO book_rating VALUES (2, 'Lord of the Ladybirds', 3); | |
INSERT INTO book_rating VALUES (3, 'Lady of the Flies', 1); | |
INSERT INTO book_rating VALUES (4, 'Lady of the Flies', 2); | |
INSERT INTO book_rating VALUES (5, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (6, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (7, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (8, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (9, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (10, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (11, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (12, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (13, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (14, 'Lady of the Flies', 5); | |
INSERT INTO book_rating VALUES (15, 'Lady of the Flies', 5); | |
// This works as expected | |
SELECT name, median(star_rating) OVER (PARTITION BY name) FROM book_rating; | |
// This doesn't work | |
SELECT name, median(star_rating) OVER (ORDER by id ROWS 3 preceding) from book_rating | |
// This works as expected | |
SELECT name, avg(star_rating) OVER (ORDER by id ROWS 3 preceding) from book_rating |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment