查询某个时间段(跨日)内每小时的数据
select type,count(*) from `table` where date >= '2012-02-04 08:00:00' and date < '2012-02-05 08:00:00' group by type
select DATE_FORMAT(`date`,'%Y%m%d%H') ,Count(*)from `table` where date >= '2012-02-04 08:00:00' and date < '2012-02-05 08:00:00' group by DATE_FORMAT(`date`,'%Y%m%d%H')
[解决办法]
select type,DATE_FORMAT(`date`,'%Y-%m-%d-%H'),count(*) from `table` where date >= '2012-02-04 08:00:00' and date < '2012-02-05 08:00:00' group by type,DATE_FORMAT(`date`,'%Y-%m-%d-%H')