summaryrefslogtreecommitdiff
path: root/mysql-test/main/win_percent_cume.test
blob: 05ace95d571ee1a5280f943c17c31e5b3bf340c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 a,
    percent_rank() over (order by a),
    cume_dist() over (order by a)
from t1;

select pk,
       percent_rank() over (order by pk),
       cume_dist() over (order by pk)
from t1 order by pk;

select a,
        percent_rank() over (partition by a order by a),
        cume_dist() over (partition by a order by a)
from t1;

drop table t1;