Groupt Query By Month

asked 2013-07-04 05:57:26 +0200

Biolore gravatar image

Basically, I want to have a query that totals monthly income and expenses, but I can't seem to find a function that will change the date to a month/year format.

I've got one working for a grand total: SELECT SUM( "DepositAmount" ) AS "Deposit", SUM( "WithdrawAmount" ) AS "Withdraw", "AccountID", ( SUM( "DepositAmount" ) - SUM( "WithdrawAmount" ) ) AS "Total" FROM "Transactions" GROUP BY "AccountID"

This one will group all transactions from the same day, but I need to change it to be by month/year: SELECT SUM( "WithdrawAmount" ) AS "Withdraw", SUM( "DepositAmount" ) AS "Deposit", "Date", "AccountID", SUM( "DepositAmount" ) - SUM( "WithdrawAmount" ) AS "Total" FROM "Transactions" GROUP BY "date"{escape '/'}, "AccountID"

image description

I blacked out stuff that isn't dummy information

edit retag flag offensive close delete