select ct.course_id, ct.course_name,
sum(case when ((hour(att.in_datetime) < 19 and hour(att.out_datetime) >= 19) or (hour(att.in_datetime) = 19 and minute(att.in_datetime) <= 0)) then 1 else 0 end) as online_num
from attend_tb as att
left join course_tb as ct using(course_id)
# group by att.course_id 报错:SQL_ERROR_INFO: "Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'ct.course_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by"
group by ct.course_id, ct.course_name
order by ct.course_id