0
可能重复:
SQL Count records within a month using a unix timestampmysql:如何按日期分组?
我有这样
+--------+------------+ | id | datetime | +--------+------------+ | 1 | 1313405609 | | 1 | 1313144410 | | 2 | 1313405550 | | 1 | 1313405549 | +--------+------------+
日期时间的表是PHP的UNIX时间,我想组行日期(如20120517)并统计每个组的项目。由于1313405609,1313405550和1313405549的日期是20110815,结果我要的是:
+--------+------------+------------+ | id | datetime | Count | +--------+------------+------------+ | 1 | 1313405609 | 2 | | 1 | 1313144410 | 1 | | 2 | 1313405550 | 1 | +--------+------------+------------+
我怎么可以用SQL做到这一点?
这可能为你工作http://stackoverflow.com/questions/6160990/sql-count-records-within-a-month-using-a-unix -timestamp –
谢谢,这就是我想要的答案 – NOrder