题解 | #牛客直播各科目平均观看时长#
牛客直播各科目平均观看时长
http://www.nowcoder.com/practice/e9e7dc4c8623467793f6999cbfee9360
select
cb.course_name,
round(
sum(
timestampdiff(MINUTE, ab.in_datetime, ab.out_datetime)
) / count(1),
2
) avg_Len
from
attend_tb ab
inner join course_tb cb on ab.course_id = cb.course_id
group by
cb.course_name
order by
avg_Len desc