题解 | #平均播放进度大于60%的视频类别#

平均播放进度大于60%的视频类别

https://www.nowcoder.com/practice/c60242566ad94bc29959de0cdc6d95ef

select b.tag,concat(round(avg(
    if (timestampdiff(second,a.start_time,a.end_time)>=b.duration,100,
       timestampdiff(second,a.start_time,a.end_time)/b.duration*100
    )),2),'%') as avg_play_progress
from tb_user_video_log as a
inner join tb_video_info as b
on a.video_id = b.video_id
group by b.video_id
having avg_play_progress>60
order by avg_play_progress desc

弱点记录:

加%号方法:concat(num,'%')

时间计算秒数:timestampdiff(second,开始的,结束的)

保留小数:round(num,2) 保留2位小数

if(条件一,结果,其他)

#刷题日记#
全部评论

相关推荐

和光同尘cc:给我发就算了,还敢恶心上交✌🏻
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务