summaryrefslogtreecommitdiff
path: root/mysql-test/main/win_percent_cume.result
blob: bc2a4182e3053c0d68f9c459cc0c2f1bc174c091 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
a	percent_rank() over (order by a)	cume_dist() over (order by a)
0	0.0000000000	0.2000000000
0	0.0000000000	0.2000000000
1	0.2222222222	0.4000000000
1	0.2222222222	0.4000000000
2	0.4444444444	0.8000000000
2	0.4444444444	0.8000000000
2	0.4444444444	0.8000000000
2	0.4444444444	0.8000000000
4	0.8888888889	1.0000000000
4	0.8888888889	1.0000000000
select pk,
percent_rank() over (order by pk),
cume_dist() over (order by pk)
from t1 order by pk;
pk	percent_rank() over (order by pk)	cume_dist() over (order by pk)
1	0.0000000000	0.1000000000
2	0.1111111111	0.2000000000
3	0.2222222222	0.3000000000
4	0.3333333333	0.4000000000
5	0.4444444444	0.5000000000
6	0.5555555556	0.6000000000
7	0.6666666667	0.7000000000
8	0.7777777778	0.8000000000
9	0.8888888889	0.9000000000
10	1.0000000000	1.0000000000
select a,
percent_rank() over (partition by a order by a),
cume_dist() over (partition by a order by a)
from t1;
a	percent_rank() over (partition by a order by a)	cume_dist() over (partition by a order by a)
0	0.0000000000	1.0000000000
0	0.0000000000	1.0000000000
1	0.0000000000	1.0000000000
1	0.0000000000	1.0000000000
2	0.0000000000	1.0000000000
2	0.0000000000	1.0000000000
2	0.0000000000	1.0000000000
2	0.0000000000	1.0000000000
4	0.0000000000	1.0000000000
4	0.0000000000	1.0000000000
drop table t1;