题解 | 输出播放量最高的视频

输出播放量最高的视频

https://www.nowcoder.com/practice/9e9cb264e1f64e28846975d5a32ba8e4

#一定要union all
with t1 as(
  select
cid,
start_time dt,
1 uv
from
play_record_tb
union all
select
cid,
end_time dt,
-1 uv
from
play_record_tb  
),
t2 as(
   select
cid,
sum(uv)over(partition by cid order by dt asc ,uv desc) sum_uv
from
t1 
)

select
cid,
max(sum_uv) sum_peak_uv
from
t2
group by cid
order by sum_peak_uv desc
limit 3

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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