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

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

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






全部评论

相关推荐

躺尸修仙中:因为很多92的也去卷中小厂,反正投递简历不要钱,面试不要钱,时间冲突就推,不冲突就面试积累经验
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务