题解 | #牛客直播各科目出勤率#

牛客直播各科目出勤率

http://www.nowcoder.com/practice/0cab547df4f0430b93042128f445d899

诡异了并不难的题花了比较多的时间……因为在workbench里可以但这里显示不行,所以重新写~脑壳痛

select a.course_id,course_name,
	   round((count(case when 在线时长 >= 10 and 在线时长 is not null and 是否签到 = 1 then user_id end)/count(case when 是否签到 = 1 then user_id end))*100,2) as 考勤率
       from
(select behavior_tb.user_id,behavior_tb.course_id,max(if_sign) as 是否签到,sum(timestampdiff(minute,in_datetime,out_datetime)) as 在线时长 
	   from 
       behavior_tb left join attend_tb on behavior_tb.user_id = attend_tb.user_id and behavior_tb.course_id = attend_tb.course_id
       group by user_id,course_id) as a
       join course_tb on a.course_id = course_tb.course_id
       group by a.course_id,course_name
       order by course_id;
全部评论

相关推荐

专业嗎喽:个人信息名字太大,合到电话邮箱那一栏就行,有党员写过党,剩下其他全删,站空太大了 把实习经历丰富,放最前面,然后是个人评价,技能之类的,然后是学校信息。项目经历最后面,可以就选一个自己擅长的。 现在是学校不是92就扣分的,没必要放前面。 然后现在看重实习经历>竞赛经历(校园经历)>课程项目经历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务