summaryrefslogtreecommitdiff
path: root/mysql-test/main/win_percent_cume.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/main/win_percent_cume.test')
-rw-r--r--mysql-test/main/win_percent_cume.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/main/win_percent_cume.test b/mysql-test/main/win_percent_cume.test
new file mode 100644
index 00000000000..b851185cb32
--- /dev/null
+++ b/mysql-test/main/win_percent_cume.test
@@ -0,0 +1,36 @@
+create table t1 (
+ pk int primary key,
+ a int,
+ b int
+);
+
+
+insert into t1 values
+( 1 , 0, 10),
+( 2 , 0, 10),
+( 3 , 1, 10),
+( 4 , 1, 10),
+( 8 , 2, 10),
+( 5 , 2, 20),
+( 6 , 2, 20),
+( 7 , 2, 20),
+( 9 , 4, 20),
+(10 , 4, 20);
+
+select pk, a, b,
+ percent_rank() over (order by a),
+ cume_dist() over (order by a)
+from t1;
+
+select pk, a, b,
+ percent_rank() over (order by pk),
+ cume_dist() over (order by pk)
+from t1 order by pk;
+
+select pk, a, b,
+ percent_rank() over (partition by a order by a),
+ cume_dist() over (partition by a order by a)
+from t1;
+
+drop table t1;
+