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

牛客直播各科目出勤率

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

注意在count参与人数的时候user_id要distinct,因为可能出现重复进入的情况 select t3.course_id,t4.course_name,t3.attend_rate from (select t1.course_id,round((t2.attend_num*100/t1.sign_num),2)attend_rate from (select course_id,count(user_id) sign_num from behavior_tb where if_sign=1 group by course_id)t1 left join (select course_id,count(distinct user_id) attend_num from attend_tb where ((unix_timestamp(out_datetime)-unix_timestamp(in_datetime))/60)>=10 group by course_id)t2 on t1.course_id=t2.course_id)t3 left join (select * from course_tb)t4 on t3.course_id=t4.course_id order by course_id

全部评论

相关推荐

Beeee0927:正确的建议
点赞 评论 收藏
分享
Lyxiho:浙江大学 加大加粗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务