当前位置:网站首页>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
边栏推荐
- [taro] applet picker dynamically obtains data
- C#入门系列(二十八) -- LINQ的查询语法
- 【Redis】redis安装与客户端redis-cli的使用(批量操作)
- pytest接口自动化测试框架 | pytest生成简单测试报告
- 软件详细设计模板
- Middle aged crisis, retired at the age of 35, what do migrant workers take to compete with capitalists?
- Une solution complète au problème du sac à dos dans la programmation dynamique
- IIS 部署.NetCore
- Calendar日历类
- V自P建N_部署使用
猜你喜欢

阿里二面:MySQL 啥时候用表锁,啥时候用行锁?

腾讯云获国际专业流媒体测评肯定:三大场景下视频编码性能全部最优

First hello of SOC_ World experiment

7、 Logic of JMeter sending request

Esp8266 nodemcu flash file system (spiffs)

锁相环工作原理,比如我们8MHZ晶振如何让MCU工作在48MHZ或者72MHZ呢

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

Middle aged crisis, retired at the age of 35, what do migrant workers take to compete with capitalists?

《STM32MP1 M4裸机CubeIDE开发指南》第六章 STM32Cube固件包

竞赛大佬在华为:网络专家出身斯坦福物理系,还有人“工作跟读博差不多”...
随机推荐
Oralce中实现将指定列的指定内容替换为想要的内容
IIS 部署.NetCore
Redis' expiration strategy and memory elimination mechanism. Why didn't you release memory when the key expired
Software detailed design template
20220721挨揍内容
20220722挨揍记录
自定义一个对象
基于USB数据采集卡(DAQ)与IO模块的热电阻温度采集「建议收藏」
【Redis】redis安装与客户端redis-cli的使用(批量操作)
C#中单例模式的实现
Bean validation beginner ----02
Oracle中实现删除指定查询条件的所有数据
数据库的备份和还原
Transparent proxy server architecture of squid proxy service
软件详细设计模板
STM32F103+RFID-RC522模块 实现简单读卡写卡demo「建议收藏」
Why is apple x charging slowly_ IPhone 12 supports 15W MagSafe wireless charging. What will happen to iPhone charging in the future_ Charger
pytest接口自动化测试框架 | 汇总
Calendar calendar class
华为新版Datacom认证介绍