How to calculate percentages? What is the correct SQL?
CREATE TABLE poll (candidate text, votes int4);
I want to do something like (this is wrong)...
SELECT candidate, votes, (votes / sum(votes)) * 100) AS percent FROM
poll;
Fred Smith | 500 | 25
Bill Bloggs | 1000 | 50
Jim Jones | 500 | 25
--
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris(dot)bitmead(at)bigfoot(dot)com