with a as(
select cid
from play_record_tb
group by cid
having avg(score)>=3
)
select cid,
count(*) as pv,
sum(timestampdiff(minute,start_time,end_time)) as time_len
from a join play_record_tb using (cid) join course_info_tb using(cid)
where timestampdiff(hour,release_date ,start_time )/24<=7
group by cid
order by pv desc,time_len desc
limit 3;

京公网安备 11010502036488号