select d.course_id,course_name,bo as"attend_rate(%)"
from course_tb d,
(select a.course_id,round(count(distinct(case when timestampdiff(minute,in_datetime,out_datetime)>=10 then a.user_id else null end ))*100/count(distinct (case when if_sign = 1 then a.user_id else null end)),2) as bo
from behavior_tb a left join attend_tb b on a.course_id=b.course_id and a.user_id=b.user_id
group by a.course_id)c
where d.course_id=c.course_id
order by course_id