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

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

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

全部评论

相关推荐

2024-12-21 18:48
西安邮电大学 C++
黑皮白袜臭脚体育生:按使用了什么技术解决了什么问题,优化了什么性能指标来写会更好另外宣传下自己的开源仿b站微服务项目,GitHub已经390star,牛客上有完整文档教程
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务