从同一天加入总和

时间:2012-03-27 21:17:19

标签: php mysql date join sum

如何从同一日期加入总和(美元)并在MySQL和PHP中按日期显示它们?

My table looks like this

ID = auto_increment

我想结果是这样的

2012-01-14 - 48
2012-02-21 - 19
2012-02-25 - 31
2012-03-01 - 11

2 个答案:

答案 0 :(得分:3)

SELECT date, SUM(dollar)
  FROM tableName
 GROUP BY date

答案 1 :(得分:2)

SELECT `DATE`, SUM(`DOLLAR`) FROM your_table GROUP BY `DATE`;

http://www.tizag.com/mysqlTutorial/mysqlgroupby.php