SQL Query创建日期和金额的记录?

时间:2011-10-25 13:31:21

标签: mysql sql

我有一张看起来像这样的表:

------------------------------------
|  ID  | Amount | Date             |
------------------------------------
|  1   | 50.00  | 10/02/2010       |
|  2   | 20.00  | 10/02/2010       |
|  3   | 30.00  | 12/02/2010       |
|  4   | 70.00  | 12/02/2010       |
|  5   | 40.00  | 12/02/2010       |
------------------------------------

现在的问题是,如何创建一个查询,将按日期汇总金额并将其分组:

10/02/2010 70.00
12/02/2010 140.00

1 个答案:

答案 0 :(得分:4)

SELECT [Date], SUM(Amount) TotalAmount
FROM YourTable
GROUP BY [Date]