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