SELECT * FROM (
SELECT t1.eventId,t1.start_date,t1.end_date, COUNT(*) pos FROM events t1
LEFT JOIN events t2 ON t1.start_date = t2.start_date AND t1.eventId <= t2.eventId
WHERE t1.start_date BETWEEN '2012-12-18' AND '2012-12-24'
GROUP BY t1.eventId,t1.start_date
ORDER BY t1.start_date,pos ASC
) t
WHERE pos <= 3;
为什么开始日期2012-12-21和2012-12-24不存在,
如果start_date不存在,那么我需要
的空值或空值注意:我的数据库中没有21和24 ..的记录,但我的结果中需要一个空值