#注意函数date_add(release_date, interval 7 day)后面的day是不能加s的('days'), 还有就是timestampdiff()
#直接使用minute不用second / 60不然不能通过
select
cid,
count(*) as pv,
round(sum(timestampdiff(minute, start_time, end_time)), 2) as time_len
from
play_record_tb as pr
where
exists (
select 1
from course_info_tb as ci
where ci.cid=pr.cid and date_add(ci.release_date, interval 7 day) > pr.start_time
)
group by pr.cid
having avg(score) >= 3
order by
pv desc,
time_len desc
limit 3


京公网安备 11010502036488号