select course_id, course_name, round(chuqing * 100 / zong, 2) as 'attend_rate(%)'
from (
    select count(distinct user_id) as chuqing, course_id
    from attend_tb
    where timestampdiff(minute, in_datetime, out_datetime) >= 10
    group by course_id
) a join (
    select count(distinct user_id) as zong, course_id
    from behavior_tb
    where if_sign = 1
    group by course_id
) b using(course_id)
right join course_tb using(course_id)
group by course_id, course_name
order by course_id