当前位置:网站首页>SQL156 各个视频的平均完播率
SQL156 各个视频的平均完播率
2022-07-23 12:45:00 【Yuki_1999】
/*
计算2021年里、有播放记录的每个视频、的完播率(结果保留三位小数),并按完播率降序排序
思路:找到处理的最小单位,从底到上书写代码,再加上限制
1、拆解定语,找到核心修饰:完播率
2、完播率=完播次数/总播放次数
——>完播次数:结束观看时间-开始播放时间>=视频时长的用户数,视为完播
end_time-start_time>=duration
**完播记为1,未完播为0,所有1相加即为完播次数
sum(if(end_time-start_time>=duration,1,0))
——>总播放次数:出现start_time为一次播放
count(start_time)
知识点:if函数,sum函数,左连接,round函数,year函数
1、left join on+条件
2、round(a,3)保留三位小数
*/
select a.video_id,round(sum(if(end_time-start_time>=duration,1,0))
/count(start_time),3) avg_comp_play_rate
from tb_user_video_log a
left join tb_video_info b
on a.video_id=b.video_id
where year(start_time)=2021
group by a.video_id
order by avg_comp_play_rate desc
边栏推荐
- 锁相环工作原理,比如我们8MHZ晶振如何让MCU工作在48MHZ或者72MHZ呢
- Hcip datacom certification examination passed in July
- 大屏可视化的适配方案
- PgSQL mistakenly deletes PG_ Wal file, service startup failed
- Memory methods of big end mode and small end mode
- V self built n_ Deployment and use
- How to solve the problem of forgetting the Oracle password
- 智慧民航新业态崭露头角,图扑数字孪生入局民航飞联网
- VMware platform STS certificate expired
- UiPath Studio Enterprise 22.4 Crack
猜你喜欢

竞赛大佬在华为:网络专家出身斯坦福物理系,还有人“工作跟读博差不多”...
![[SUCTF 2018]MultiSQL(mysql预编译)](/img/ae/501b7f9c6d8259c3c799e4ff0b568b.png)
[SUCTF 2018]MultiSQL(mysql预编译)

【Redis】redis安装与客户端redis-cli的使用(批量操作)

7、 Logic of JMeter sending request

Ora-01654 error: table space is full, insert failed

自定义一个对象

Complete knapsack explanation of dynamic programming knapsack problem

Une solution complète au problème du sac à dos dans la programmation dynamique

946. Verify stack sequence ●● & sword finger offer 31. stack push in and pop-up sequence ●●

How to choose fluorescent dyes in laser confocal
随机推荐
mysql多表查询之_笛卡尔乘积_内连接_隐式连接
Bean Validation核心組件篇----04
Hcip datacom certification examination passed in July
Do you know why PCBA circuit board is warped?
The competition boss is in Huawei: network experts are from Stanford physics department, and some people "work as much as reading a doctoral degree"
距7月30日PMP考试不足10天,应该做点什么?
pytest接口自动化测试框架 | pytest常用运行参数
fastadmin,非超级管理员,已赋予批量更新权限,仍显示无权限
博客表情大全
pytest接口自动化测试框架 | 汇总
Une solution complète au problème du sac à dos dans la programmation dynamique
Complete knapsack explanation of dynamic programming knapsack problem
Convert.Calss file to.Jar idea
反转链表画图演示
V自P建N_部署使用
Oralce中实现将指定列的指定内容替换为想要的内容
946. Verify stack sequence ●● & sword finger offer 31. stack push in and pop-up sequence ●●
Sealing agent glycerol sealing neutral resin sealing dosage form
How to choose fluorescent dyes in laser confocal
Backup and restore of database