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')
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')
你好。这个查询该段时间内的数据没问题。但是如果还要针对type做group by查询该怎样?
正解!好久没写sql语句了。大概都忘得差不多了。