题解 | #各个视频的平均完播率#
平均播放进度大于60%的视频类别
http://www.nowcoder.com/practice/c60242566ad94bc29959de0cdc6d95ef
select
t2.tag,
concat(t2.avg_p,'%')
from
(
select
t1.tag,
round(avg(t1.diff) * 100,2) avg_p
from
(
select
if((TIME_TO_SEC(tu.end_time) - TIME_TO_SEC(tu.start_time))/tb.duration > 1,1
,(TIME_TO_SEC(tu.end_time) - TIME_TO_SEC(tu.start_time))/tb.duration) diff,
tb.tag
from
tb_user_video_log tu
join
tb_video_info tb
on
tu.video_id = tb.video_id
) t1
group by
t1.tag
) t2
where
t2.avg_p > 60
order by
t2.avg_p desc
t2.tag,
concat(t2.avg_p,'%')
from
(
select
t1.tag,
round(avg(t1.diff) * 100,2) avg_p
from
(
select
if((TIME_TO_SEC(tu.end_time) - TIME_TO_SEC(tu.start_time))/tb.duration > 1,1
,(TIME_TO_SEC(tu.end_time) - TIME_TO_SEC(tu.start_time))/tb.duration) diff,
tb.tag
from
tb_user_video_log tu
join
tb_video_info tb
on
tu.video_id = tb.video_id
) t1
group by
t1.tag
) t2
where
t2.avg_p > 60
order by
t2.avg_p desc