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

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

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

with cte as (
select uid,search_num,ifnull(click_num,0) as click_num from 
(
select uid,search_num
from (
select uid,count(*) as search_num
from search_log_tb
group by uid ) a ) c left join 
(
select uid,click_num
from (
select uid,count(*) as click_num
from click_log_tb
group by uid ) b ) d using(uid) ),
cte1 as(
select *,rank()over(order by search_num desc) as search_rank,
         rank()over(order by click_num desc) as click_rank
from cte )
select *
from cte1
where search_rank<=3 or click_rank<=3
order by click_rank,uid






全部评论

相关推荐

10-11 17:45
门头沟学院 Java
走吗:别怕 我以前也是这么认为 虽然一面就挂 但是颇有收获!
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务