select a.course_id,a.course_name,count(distinct b.user_id) as online_pv
from course_tb a
left join attend_tb b on a.course_id=b.course_id
where time(b.in_datetime)<='19:00:00'
group by 1,2 order by 1