我有以下MySQL数据库:
http://sqlfiddle.com/#!2/7d82f
我如何确保获得按时间分组的最大金额? 所以我会得到:
Max(hitId) | dte | time
1 | 2015-01-18 | 19:00:00
2 | 2015-01-18 | 20:00:00
1 | 2015-01-18 | 21:00:00
2 | 2015-01-18 | 22:00:00
但我不想得到上次约会。 所以只有日期是'2015-01-18'(或者我放的任何东西)
答案 0 :(得分:2)
SELECT COUNT( hitId ) AS Max_hits, dte AS sDate, TIME AS sTime
FROM hitcounter
WHERE dte = '2015-01-18'
GROUP BY sTime
ORDER BY sDate ASC