mySQL subqueries calculating winning percentage I have a table where I store the data of a random dice game where you win if you get a sum of 7 between the two dices. Here's the table:




id
result
dice1
dice2
player_id




1
LOSE
4
4
9


2
LOSE
4
5
7


3
WIN
4
3
9


4
LOSE
2
3
9


5
WIN
6
1
7


6
WIN
1
6
7


7
LOSE
1
3
7




I need to display the percentage of win of each player and this is the query right now but it's not working, it gives me back the same percentage for every player:
SELECT DISTINCT player_id,
ROUND(((SELECT COUNT(id_game) FROM game WHERE result = 'WIN' ) / 
(SELECT COUNT(id_game) FROM game )) * 100 ) AS percentage
FROM game
group by player_id

Do you think it's even possible to do that? I'm starting to doubt it
SELECT player_id,
       COUNT(result) total,
       ROUND(100 * SUM(result = 'WIN') / COUNT(result)) winning_percent,
       ROUND(100 * SUM(result = 'LOSE') / COUNT(result)) loosing_percent
FROM game
GROUP BY player_id;

https://dbfiddle.uk/?rdbms=mysql_8.0&amp;fiddle=a04d576b918c392f90c1d835fd1a6f51