题解 | #广告点击率排名#

广告点击率排名

https://www.nowcoder.com/practice/489a4e583a4549ba8d788212469276e6

with cte as(
select uid,sum(is_click)/count(*) as rk_7
from user_res_event_log_tb
where rid like 'ad%' and left(event_date,7)='2022-07'
group by uid
order by rk_7 desc ,uid desc
limit 3   ),
cte1 as (
select uid,ctr_2208,rank()over(order by ctr_2208 desc,uid desc) as rk_ctr
from (
select uid,round(sum(is_click)/count(*),3) as ctr_2208
from user_res_event_log_tb
where rid like 'ad%' and left(event_date,7)='2022-08'
group by uid
order by ctr_2208 desc,uid desc ) a )
select * 
from cte1
where uid in (select uid from cte)
order by uid

稍后补一下为什么用rank不能先聚合后开窗的问题

全部评论
是受了order by的影响
点赞 回复 分享
发布于 2024-03-23 15:08 北京

相关推荐

程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 14:10
啊啊啊啊好幸福,妈妈是我找工作发疯前的一束光
榕城小榕树:你是我见过最幸福的牛客男孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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