這需要用到自連接查詢也就是自己連接自己
select * from bbjobcourse a inner join bbjobcourse b where a.ct_id=b.ct_id and a.z_datetime<=b.z_datetime
<=則出來時間的倒序
group by a.ct_id,a.z_datetime
group by根據id和時間分組查詢
HAVING COUNT(a.ct_id)<=n
having篩選出你需要的前n條數據