I have two tables:
Table alpha:
ID | Name
---------
1 | A
2 | B
3 | C
Table beta:
ID | state
----------
1 | 1
1 | 2
1 | 2
2 | 1
I would like to get a result like the following:
ID | Count(state=1) | Count (state=2)
-------------------------------------
1 | 1 | 2
2 | 1 | 0
3 | 0 | 0
How do I do this with SQL?
I can get the table without the result of ID 3, but that is not what I want.
Thanks in advance!
1 Answer