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

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

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

select tag, avg_play_progress
from (
    select tag, CONCAT(FORMAT(AVG(play_progress)*100, 2),'%') as avg_play_progress
    from (
        select uid, tag, 
        (case when watch_time >= duration then 1
        else watch_time/duration end) as play_progress
        from (
            select uid, a.video_id,
            TIMESTAMPDIFF(SECOND, start_time, end_time) as watch_time, tag, duration
            from tb_user_video_log as a
            left join tb_video_info as b
            on a.video_id = b.video_id
        ) as c
    ) as d
    group by tag
    order by avg_play_progress desc
) as e
where CAST(SUBSTRING(avg_play_progress, 1, LENGTH(avg_play_progress)-1) AS DECIMAL(5,2)) > 60.00;

全部评论
1,将整数转换成字符串类型的百分数形式:使用FORMAT,然后使用拼接函数将%进行拼接到后面; 2,字符串类型的数字形式与整数进行比较:使用SUBSTRING将数字类型的字符串提取出来,用CAST函数转为整形,然后进行比较。
点赞 回复 分享
发布于 2023-08-02 23:59 江苏

相关推荐

叶扰云倾:进度更新,现在阿里云面完3面了,感觉3面答得还行,基本都答上了,自己熟悉的地方也说的比较细致,但感觉面试官有点心不在焉不知道是不是不想要我了,求阿里收留,我直接秒到岗当阿里孝子,学校那边的房子都退租了,下学期都不回学校,全职猛猛实习半年。这种条件还不诱人吗难道 然后现在约到了字节的一面和淘天的复活赛,外加猿辅导。华为笔试完没动静。 美团那边之前投了个base广州的,把我流程卡麻了,应该是不怎么招人,我直接简历挂了,现在进了一个正常的后端流程,还在筛选,不知道还有没有hc。
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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