Percentages?

Поиск
Список
Период
Сортировка
От Chris Bitmead
Тема Percentages?
Дата
Msg-id 3721B398.DF32C1EC@bigfoot.com
обсуждение исходный текст
Ответ на Finding the "most recent" rows  (Julian Scarfe <jas1@scigen.co.uk>)
Список pgsql-sql
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.bitmead@bigfoot.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: Chris Bitmead
Дата:
Сообщение: Re: [SQL] Large objects - bug? caveat? feature?
Следующее
От: Chris Bitmead
Дата:
Сообщение: Confusion about DISTINCT.