当前位置:网站首页>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
边栏推荐
- YOLOv4: Optimal Speed and Accuracy of Object Detection
- 二,数字逻辑功能单元
- Interface test
- 【Unity3D日常BUG】Unity3D解决“找不到类型或命名空间名称“XXX”(您是否缺少using指令或程序集引用?)”等问题
- TAP 系列文章9 | 应用开发加速器
- Three network modes of VMware virtual machine
- Contemporary inspirational "women"
- strncat() strncmp()
- 2、 Digital logic functional unit
- Merge.Avhd into.Vhd manually in Hyper-V
猜你喜欢

The ultimate experiment of OSPF -- learn the example of OSPF century template

ES6 other syntax and extended syntax summary

TAP 系列文章7 | 易于管理的流水线配置

TOPSIS method (matlab)

使用itextpdf提取PDF文件中的任意页码

Mongodb database + graphical tools download, installation and use

Principal component analysis (matlab)

Redis pipeline technology / partition

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

dried food! Implicit sparse regularization effect in neural networks
随机推荐
浅析基于NVR技术的视频能力与未来发展趋势
Lin Zhiying's injury is relatively stable
strncat() strncmp()
How to reasonably estimate the size of thread pool
一,数字逻辑的化简
糖尿病遗传风险检测挑战赛Baseline
Getting started database Days1
Data sorting and usage before torchvision.datasets.imagefolder
Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
Contemporary inspirational "women"
As a developer, you have to know the three performance testing tools JMeter, API and jmh user guide
YOLOv4: Optimal Speed and Accuracy of Object Detection
Analysis of video capability and future development trend based on NVR Technology
The role of physical layer, link layer, network layer, transport layer and application layer of tcp/ip model of internet protocol stack
疑似未系安全带 林志颖伤势相对稳定
USB to can device in nucleic acid extractor high performance USB interface can card
Crazy God redis notes 10
Analytic hierarchy process (matlab)
2022-7-22 face review + simple topic sorting
Grey correlation analysis (matlab)