MySQL Multiple Subquery on same table
- by user1444980
I have a table of the following structure
ID | Amount | Bank (1 or 2)
---+--------+------
1 | 100000 | 1
2 | 256415 | 2
3 | 142535 | 1
1 | 214561 | 2
2 | 123456 | 1
1 | 987654 | 2
I want a result like this (from the same table):
ID | sum(Bank 1) | sum(Bank 2)
---+-------------+------------
1 | 100000 | 1202215
2 | 123456 | 256415
3 | 142535 | 0
What will be the easiest query to achieve this?