select  p.cid, count(1) as pv , sum(timestampdiff(minute , start_time ,end_time) ) as time_len
from play_record_tb p
inner join course_info_tb c on p.cid = c.cid
where timestampdiff(hour ,release_date, start_time)/24 <=7
group by p.cid
having avg(score) >=3
order by 2 desc , 3 desc 
limit 3;