On a website I run, I let users rate the individual posts (3, 2, 1). I use the following SQL (in MySQL) to get the percentage of votes of each value:
SELECT vote, COUNT(*) * t.factor AS pct
FROM ratings
JOIN (
SELECT 100 / COUNT(*) AS factor
FROM ratings
) AS t
GROUP BY vote
LIMIT 0, 30;
That works fine for calculating the percentage of rows for the whole table. Now, I need the percentages just for a particular post, identified in the table by the column "id". How might I do that?