题解 | #国庆期间每类视频点赞量和转发量#
国庆期间每类视频点赞量和转发量
https://www.nowcoder.com/practice/f90ce4ee521f400db741486209914a11
select tag, dt1, sum(日总点赞量), max(日总转发量)
from
(
select tag, e.dt dt1, d.dt dt2, sum(if_like) 日总点赞量, sum(if_retweet) 日总转发量
from
(select tag, date(start_time) dt, if_like, if_retweet
from tb_user_video_log a right join tb_video_info b
on a.video_id=b.video_id and (date(start_time) between date_sub('2021-10-01', interval 7 day) and '2021-10-03')) d,
(select '2021-10-01' dt union select '2021-10-02' dt union select '2021-10-03' dt) e
where d.dt > date_sub(e.dt, interval 7 day) and d.dt <= e.dt
group by tag, e.dt, d.dt
order by tag, e.dt, d.dt
) f
group by tag, dt1
order by tag desc, dt1 asc
随便写写 我发现这个东西是真的看状态 前段时间到这里脑子跟断线一样想不出 但是隔了好久想起来做一下居然也就过了 真的头秃