0

表中有两列:Datestamp如 2012-12-16 和 typedateTimestamp12:22:59 和 type time。是否可以使用 1 个 sql 获取特定日期每小时的行数?返回时我需要获得 24 个数字。

4

2 回答 2

2

像这样的东西:

SELECT COUNT(*) FROM your_table 
WHERE `Datestamp` = '2012-12-16' 
GROUP BY HOUR(`Timestamp`)
于 2012-12-16T09:29:25.570 回答
0
SELECT datestamp as day, hour(timestamp) as hour, count(*)
FROM your_table
GROUP BY datestamp, hour(timestamp)
于 2012-12-16T09:30:01.147 回答