Re: Percentage of Total Occurances - Mailing list pgsql-sql

From Adam Sherman
Subject Re: Percentage of Total Occurances
Date
Msg-id 30270000.1050433172@saturn
Whole thread Raw
In response to Re: Percentage of Total Occurances  (<mallah@trade-india.com>)
Responses Re: Percentage of Total Occurances
List pgsql-sql
On 04/15/03 22:40:37 +0530 mallah@trade-india.com wrote:

>> I have a table being used for poll results:
>>
>> id
>> poll_id
>> question_id
>> answer_id
>> datestamp
>>
>> I what to figure out the percentage or respondants that gave each
>> answer.  This is based on occurance rather than values.
>
> select answer_id,count(*) from polls where poll_id = ?
> group by answer_id ;
>
> gives number of response of each answer
>
> total_response = select count(*) from polls where poll_id = ?
>
> getting %age shud be trivial.
>
> Dunno if i missed your question .

I'm looking to do everything in a single query.

And get something like:

answer_id -> percentage

Thanks,

A.

--
Adam Sherman
Tritus CG Inc.
http://www.tritus.ca/
+1 (613) 797-6819



pgsql-sql by date:

Previous
From: Guy Fraser
Date:
Subject: What is the scope of a temp table?
Next
From: Fernando Eduardo Carvalho
Date:
Subject: plpgsql slow in 7.3 ????