P
Peter Morris
I have a TRANSACTIONS table showing activity
in various accounts.
fields include:
- account_id,
- date,
- amount_in
- amount_out
- type
Transaction types might be
- deposit
- withdrawal
- transfer
- charge
I want to show the sum of each transaction type grouped by account_id
I can't work out the syntax for this query, but something like :
SELECT
account_id,
sum (transactions.[amount_in]) as deposit where type = "deposit",
sum (transactions.[amount_out]) as charge where type = "charge",
sum (transactions.[amount_out]) as withdrawal where type =
"withdrawal"
FROM
transactions
GROUP BY
account_id
How do I do this? Is it even possible?
in various accounts.
fields include:
- account_id,
- date,
- amount_in
- amount_out
- type
Transaction types might be
- deposit
- withdrawal
- transfer
- charge
I want to show the sum of each transaction type grouped by account_id
I can't work out the syntax for this query, but something like :
SELECT
account_id,
sum (transactions.[amount_in]) as deposit where type = "deposit",
sum (transactions.[amount_out]) as charge where type = "charge",
sum (transactions.[amount_out]) as withdrawal where type =
"withdrawal"
FROM
transactions
GROUP BY
account_id
How do I do this? Is it even possible?