题解 | #每个人的累计搜索点击数排名#

每个人的累计搜索点击数排名

https://www.nowcoder.com/practice/e66514c25a814029995313962cd44d62



select 
t1.uid,
t1.search_num,
t1.click_num,
t1.m as search_rank,
t1.py as click_rank
from(
select
t.uid,
t.search_num,
t.click_num,
dense_rank()over(order by t.search_num desc) as m,
dense_rank()over(order by t.click_num desc) as py
from(
select 
tg.uid,
ifnull(count(distinct tg.id),0) as search_num,
ifnull(count(distinct cb.id),0) as click_num
from search_log_tb tg left join click_log_tb cb 
on tg.uid=cb.uid
group by tg.uid
) as t 
) as t1
where
t1.m+1<=3
or
t1.py+1<=3

全部评论

相关推荐

昨天 13:48
门头沟学院 C++
点赞 评论 收藏
分享
07-07 10:44
青岛工学院 Java
机械打工仔:对方没做错任何事,你自己在这自找没趣呢,就算他工资不高,人家定多少薪资是人家的事,况且人家写了1~3年清清楚楚
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 14:00
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务