Hey,
Just wondering if someone could have a look at my comments in the below line, just to confirm if my explanation is actually correct?
Is the first COUNT(*) calculating total number of all rows, then * by 100
Then this is being divided by total number of rows (not multiplied)
As this is grouped by race_group, the result would be a table for each unique entry in race_group and their proportions?
Screen Link:
My Code:
SELECT race_group, COUNT(*) * 100.0 / (SELECT COUNT(*) AS overall
FROM performance) AS proportion
FROM performance
GROUP BY race_group;
-- COUNT(*) * 100.0 to obtain total number rows * 100
-- divided by total number of rows
-- all GROUP BY race_group
-- meaning, if there's 10 rows in GROUP A, then total number of rows / 10
Thanks!