問題:
I have the following database table on a Postgres server:我在 Postgres 服務器上有以下數據庫表:
id date Product Sales
1245 01/04/2013 Toys 1000
1245 01/04/2013 Toys 2000
1231 01/02/2013 Bicycle 50000
456461 01/01/2014 Bananas 4546
I would like to create a query that gives the SUM
of the Sales
column and groups the results by month and year as follows:我想創建一個查詢,該查詢給出Sales
列的SUM
並按月和年對結果進行分組,如下所示:
Apr 2013 3000 Toys
Feb 2013 50000 Bicycle
Jan 2014 4546 Bananas
Is there a simple way to do that?有沒有一種簡單的方法可以做到這一點?
解決方案:
參考一: https://en.stackoom.com/question/1BOVj參考二: https://stackoom.com/question/1BOVj