with a as(
select
ct.course_id,
ct.course_name,
count(distinct at.user_id) as online_num
from
attend_tb as at
left join course_tb as ct on at.course_id=ct.course_id
where
time(at.in_datetime)<='19:00:00' and time(at.out_datetime)>='19:00:00'
group by
ct.course_id,
ct.course_name
order by
ct.course_id
)
select * from a

京公网安备 11010502036488号