I'm trying to select the amount of times a player has won and lost in the following table for each player name that exists in the table.
This table holds games played.
┌──┬────────┬────────┐ │id│winner │loser │ ├──┼────────┼────────┤ │1 │player1 │ player2│ ├──┼────────┼────────┤ │2 │player1 │ player2│ ├──┼────────┼────────┤ │3 │player2 │ player1│ ├──┼────────┼────────┤ │4 │player3 │ player2│ └──┴────────┴────────┘
Example: In the above table, player1 would have two wins and one loss. I'm trying to select the amount of wins and losses each player has.
I currently have the following SQL
SELECT winner, count(winner) FROM multiplayergamestbl GROUP BY winner
This will return each player along with their wins, but the count of losses is not what I'm expecting, count of losses will return the same value as the count of wins. I'm clearly a bit new to SQL, can someone help me?