当前位置:网站首页>Sql156 average completion rate of each video
Sql156 average completion rate of each video
2022-07-23 23:16:00 【Yuki_ one thousand nine hundred and ninety-nine】
/*
Calculation 2021 In the year 、 Every video with playback record 、 The completion rate of broadcasting ( The result is three decimal places ), And sort them in descending order according to the completion rate
Ideas : Find the smallest unit of processing , Write code from bottom to top , Add restrictions
1、 Disassemble attributive , Find the core decoration : Completion rate
2、 Completion rate = Number of finished broadcasts / Total playback times
——> Number of finished broadcasts : End viewing time - Start playback time >= Number of users with video duration , Deemed as finished broadcasting
end_time-start_time>=duration
** The end of the broadcast is recorded as 1, The unfinished broadcast is 0, all 1 The sum is the completion times
sum(if(end_time-start_time>=duration,1,0))
——> Total playback times : appear start_time For one play
count(start_time)
Knowledge point :if function ,sum function , Left connection ,round function ,year function
1、left join on+ Conditions
2、round(a,3) Keep three decimal places
*/
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
边栏推荐
- Interviewer: if the order is not paid within 30 minutes after it is generated, it will be automatically cancelled. How to realize it?
- ES6 other syntax and extended syntax summary
- After reading this article, thoroughly understand grpc!
- 13. Roman to integer
- The Minesweeper game
- Notes on network segment CIDR
- 1、 Simplification of digital logic
- 激光雷达点云数据录制的rosbag文件转换成csv文件
- strncat() strncmp()
- ES6 use of arrow function
猜你喜欢

H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)

1000 okaleido tiger launched binance NFT, triggering a rush to buy
![[laser principle and Application-8]: EMC design of laser circuit](/img/98/8b7a4fc3f9ef9b7e16c63a8c225b02.png)
[laser principle and Application-8]: EMC design of laser circuit
The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)

How to reasonably estimate the size of thread pool

Rails with OSS best practices

The I2C interface mode offline burning operation method of h7-tool has been released (2022-07-16)

糖尿病遗传风险检测挑战赛Baseline

Diabetes genetic risk testing challenge advanced

【Unity3D日常BUG】Unity3D解决“找不到类型或命名空间名称“XXX”(您是否缺少using指令或程序集引用?)”等问题
随机推荐
mysqlbinlog命令介绍(远程拉取binlog日志)
Mobile, telecom and Unicom: fancy solution of 5g to B
1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
Tap series article 7 | easy to manage pipeline configuration
系列文章|云原生时代下微服务架构进阶之路 - 微服务拆分的最佳实践
H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)
Principal component analysis (matlab)
The canfd/can interface offline burning operation instructions of h7-tool have been updated (2022-07-12)
视频号加强打击低俗内容:对违背公序良俗的内容必须赶尽杀绝
Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
Classification model - logistic regression, Fisher linear discriminant (SPSS)
SOLIDWORK learning notes: Sketch geometric relationships and editing
Programming in the novel [serial 16] the moon bends in the yuan universe
48: Chapter 5: develop admin management service: 1: create sub project [imooc news dev Service Admin], management service module;
Smart IOT source code with configuration IOT source code industrial IOT source code: support sensor analysis services, real-time data collection and remote control
Brief analysis of compiling principle of.Net CLR R2R
糖尿病遗传风险检测挑战赛进阶
[unity3d daily bug] unity3d solves "the type or namespace name" XXX "cannot be found (are you missing the using directive or assembly reference?)" Etc
D1-h development board - Introduction to Nezha development
FL Studio 20.9 update Chinese version host Daw digital audio workstation