题解 | #牛客直播开始时各直播间在线人数#
牛客直播开始时各直播间在线人数
http://www.nowcoder.com/practice/bdd30e83d47043c99def6d9671bb6dbf
熟练掌握时间戳函数即可,有date_format,timestampdiff,timestampadd
select cou.course_id,course_name,count(distinct user_id) as cnt
from course_tb cou right join attend_tb att using(course_id)
where date_format(in_datetime,"%Y-%m-%d")=date_format(course_datetime,"%Y-%m-%d")
and date_format(in_datetime,"%T")<="19:00:00"
and date_format(out_datetime,"%T")>"19:00:00"
GROUP BY cou.course_id