hive函数row_numberrank和dense_rank的对比
Posted HoweSea
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive函数row_numberrank和dense_rank的对比相关的知识,希望对你有一定的参考价值。
不讲别的,直接看结果
select
score,
row_number() over (order by score desc) as `row_number`,
rank() over (order by score desc) as `rank`,
dense_rank() over (order by score desc) as `dense_rank`
from
(
select 100 as score union all
select 95 as score union all
select 95 as score union all
select 90 as score
) t;
+--------+-------------+-------+-------------+
| score | row_number | rank | dense_rank |
+--------+-------------+-------+-------------+
| 100 | 1 | 1 | 1 |
| 95 | 2 | 2 | 2 |
| 95 | 3 | 2 | 2 |
| 90 | 4 | 4 | 3 |
+--------+-------------+-------+-------------+
以上是关于hive函数row_numberrank和dense_rank的对比的主要内容,如果未能解决你的问题,请参考以下文章