I have this table named playergame.
| id | gameid | player | win |
|---|---|---|---|
| 1 | 1 | jon | true |
| 2 | 1 | dan | true |
| 3 | 1 | lee | false |
| 4 | 2 | jon | false |
| 5 | 2 | jon | true |
| 6 | 3 | lee | true |
I want to get all games where jon and dan have won playing together. I think I may be able to do this with something like:
SELECT count(*) as wins
FROM playergame
WHERE player = 'dan' AND player = 'jon' AND win = true
GROUP BY gameid
However I need to factor in that I'm wanting to merge and query two rows into 1. How can I do this?