DENSE_RANK()" 函数是否适用于 MySQL?
is the DENSE_RANK()" function applicable in MySQL?
以下 MySQL 代码或“DENSE_RANK()”函数在 MySQL 中是否有效,还是仅在 Oracle 数据库中使用???
Select Employee, Cost_Center, Cost_Grant, Percent
,DENSE_RANK() over (PARTITION BY Employee order by Percent ASC) as Rank
Employee
Cost_Center
Cost_Grant
Percent
AB61526
10030
54
AB61526
14020
46
AB60020
1040
68
AB60020
10010
32
AB60038
11000
71
AB60038
10010
29
AK50051
10020
23
AK50051
11520
78
预期结果输出:
Employee
Cost_Center
Cost_Grant
Percent
Rank
AB61526
10030
54
1
AB61526
14020
46
2
AB60020
1040
68
2
AB60020
10010
32
1
AB60038
11000
71
2
AB60038
10010
29
1
AK50051
10020
23
1
AK50051
11520
78
2
DENSE_RANK 从 8.0 版开始支持 mysql,从 10.2 版开始在 MariaDB 中支持。
以下 MySQL 代码或“DENSE_RANK()”函数在 MySQL 中是否有效,还是仅在 Oracle 数据库中使用???
Select Employee, Cost_Center, Cost_Grant, Percent
,DENSE_RANK() over (PARTITION BY Employee order by Percent ASC) as Rank
Employee | Cost_Center | Cost_Grant | Percent |
---|---|---|---|
AB61526 | 10030 | 54 | |
AB61526 | 14020 | 46 | |
AB60020 | 1040 | 68 | |
AB60020 | 10010 | 32 | |
AB60038 | 11000 | 71 | |
AB60038 | 10010 | 29 | |
AK50051 | 10020 | 23 | |
AK50051 | 11520 | 78 |
预期结果输出:
Employee | Cost_Center | Cost_Grant | Percent | Rank |
---|---|---|---|---|
AB61526 | 10030 | 54 | 1 | |
AB61526 | 14020 | 46 | 2 | |
AB60020 | 1040 | 68 | 2 | |
AB60020 | 10010 | 32 | 1 | |
AB60038 | 11000 | 71 | 2 | |
AB60038 | 10010 | 29 | 1 | |
AK50051 | 10020 | 23 | 1 | |
AK50051 | 11520 | 78 | 2 |
DENSE_RANK 从 8.0 版开始支持 mysql,从 10.2 版开始在 MariaDB 中支持。