我的桌子:
select * from A
我想要的输出:
根据观看次数的降序,每个用户ID每月排名前2的类别。
以表格形式将是:
我尝试了这个,但是我不太明白我在做什么错
select userid, category, month, views
from A
qualify
row_number() over (partition by userid, category, month order by views desc) = 2
答案 0 :(得分:0)
您是说这个意思吗?
select userid, category, month, views
from A
qualify
row_number() over (partition by userid, month order by views desc) <= 2