The following SQL statement:
x
SELECT FTR, COUNT(FTR)
FROM football_data
WHERE Matchday >= '2019-01-18'
GROUP BY FTR
Returns the following result:
Now I’m trying to get a percentage for each of those COUNT(FTR)’s.
So the sum of those 3 numbers is 153. Now I would like to get the percentage of them
Advertisement
Answer
You can use window functions, if I understand correctly:
SELECT FTR, COUNT(*),
COUNT(*) * 1.0 / SUM(COUNT(*)) OVER () as ratio
FROM football_data
WHERE Matchday >= '2019-01-18'
GROUP BY FTR;