I've got a table that looks like this
Savings
ID | Name | Type | Amount | Date
1 | Alex | Cash | 100 | 2019-06-10
2 | Nick | CHQ | 500 | 2019-06-10
3 | Mike | Cash | 700 | 2019-06-10
4 | Luke | CHQ | 200 | 2019-06-10
5 | Alex | Card | 300 | 2019-06-10
6 | Alex | Card | 100 | 2019-06-10
7 | Luke | Cash | 900 | 2019-06-10
8 | Alex | Cash | 400 | 2019-06-10
9 | Mike | CHQ | 200 | 2019-06-10
is it possible to sort it out in this manner using only 1 select statement?
Final Output
Name | Total Amount | Total Cash | Total Chq
Mike | 900 | 700 | 200
Luke | 1100 | 900 | 200
Alex | 500 | 500 | 0
Nick | 500 | 0 | 500
This is my current statement
SELECT
name,
SUM(amount)
FROM
savings
WHERE
date = '2019-06-10' AND
type = 'Cash' OR date = '2019-06-10' AND
type = 'Chq'
GROUP BY
name
ORDER BY
SUM(amount) DESC
All help appreciated. thanks