赞
踩
看到一篇写的很好的总结了,就把链接附上把,我们主要是结合一些题目看一下具体的用法(https://blog.csdn.net/scgaliguodong123_/article/details/60135385)
分为两类,
数据很简单,是自己随便做的一个成绩单。用这个数据集将做些逐渐深入的用例(后续可能会追加)
用途:研究复购率、多次进线数等
select ID,
sub,
score,
row_number() over(partition by ID order by score desc)
from sc ;
select
a.ID,
a.sub,
a.score,
a.rk
from (
select *,
rank() over(partition by ID order by score desc) as rk
from sc
) a
where rk <= 2
select
a.sub,
a.ID,
a.score,
a.rk
from (
select *,
rank() over(partition by sub order by score desc) as rk
from sc
) a
where rk <= 2
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。