select a.course_id,
b.course_name,
count(distinct user_id) online_num
from attend_tb a
left join course_tb b
on a.course_id = b.course_id
where '19:00' between DATE_FORMAT(in_datetime,'%H:%i') and DATE_FORMAT(out_datetime,'%H:%i')
group by a.course_id,b.course_name
order by a.course_id