Skip to content

Commit

Permalink
Test case added for the percentile disc function
Browse files Browse the repository at this point in the history
  • Loading branch information
varunraiko committed Nov 1, 2017
1 parent ba9fbc6 commit d2214da
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions mysql-test/t/percentile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
CREATE TABLE student (name CHAR(10), test double, score TINYINT);

INSERT INTO student VALUES
('Chun', 0, null), ('Chun', 0, 4),
('Esben', 1, null), ('Esben', 1, null),
('Kaolin', 0.5, 56), ('Kaolin', 0.5, 88),
('Tatiana', 0.8, 2), ('Tatiana', 0.8, 1);



select name, percentile_disc(0.6) within group(order by score) over (partition by name) from student;
select name, percentile_disc(test) within group(order by score) over (partition by name) from student;
select name, percentile_disc(0.4) within group(order by score) over (partition by name) from student;


#select name, percentile_cont(null) within group(order by score) over (partition by name) from student;
#select name, cume_dist() over (partition by name order by score) from student;


#normal parsing
#select percentile_cont(0.5) within group(order by score) over w1 from student
#window w1 AS (partition by name);

# no partition clause
#select percentile_cont(0.5) within group(order by score) over () from student;


# only one sort allowed
#select percentile_cont(0.5) within group(order by score) over (partition by name);

#parameter value should be in the range of 0 to 1
#select percentile_cont(1.5) within group(order by score) over (partition by name);


#
#select rank() over (partition by name order by score ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) from student;



drop table student;

0 comments on commit d2214da

Please sign in to comment.