SQL188 牛客直播各科目出勤率
首先需要对attend_tb表进行预处理,把一天内多次登录的数据只保留一条数据,避免出现重复计算,同时筛选出观看时长大于等于10的数据
with t1 as (
select distinct
user_id,course_id
from
attend_tb
where
timestampdiff(minute,in_datetime,out_datetime)>=10
)
select
behavior_tb.course_id
,course_name
,round(count(t1.user_id)*100/sum(if_sign),2) `attend_rate(%)`
from
course_tb right join behavior_tb on course_tb.course_id=behavior_tb.course_id
left join t1 on behavior_tb.course_id=t1.course_id and
behavior_tb.user_id=t1.user_id
group by
behavior_tb.course_id,course_name
order by
course_id asc
with t1 as (
select distinct
user_id,course_id
from
attend_tb
where
timestampdiff(minute,in_datetime,out_datetime)>=10
)
select
behavior_tb.course_id
,course_name
,round(count(t1.user_id)*100/sum(if_sign),2) `attend_rate(%)`
from
course_tb right join behavior_tb on course_tb.course_id=behavior_tb.course_id
left join t1 on behavior_tb.course_id=t1.course_id and
behavior_tb.user_id=t1.user_id
group by
behavior_tb.course_id,course_name
order by
course_id asc
全部评论
相关推荐
点赞 评论 收藏
分享
牛客20646354...:这连小厂都找不到就离谱,只能说可能你根本没投什么小厂。说实话现在都要11月了,没什么岗位了。其实最好是在9月找,那时候暑假工刚走,岗位多的是,现在都占满了岗位了,秋招的秋招,顶替暑假工的也基本上都顶替了。 只能多投了,简历其实都差不多,你这都不是外卖+点评去找实习了,已经比好多人优秀了。实在找不到,可以降低一些标准的,能投到自研项目的小厂说实话可能比你去中大厂能学到更多东西。因为中大厂最多给你看一点点模块功能,小厂基本上全部代码甚至几个项目的代码都能拿到。 点赞 评论 收藏
分享
安克创新 Anker公司福利 817人发布