题解 | #每个人的累计搜索点击数排名#
每个人的累计搜索点击数排名
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