From: Adam Sherman <adam@tritus.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Percentage of Total Occurances
Date: Tue, 15 Apr 2003 14:59:32 -0400
Message-ID: <30270000.1050433172@saturn> (raw)
In-Reply-To: <1177.219.65.253.230.1050426637.squirrel@mail.trade-india.com>
References: <6790000.1050418432@saturn>
<1177.219.65.253.230.1050426637.squirrel@mail.trade-india.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: adam@tritus.ca
Subject: Re: Percentage of Total Occurances
In-Reply-To: <30270000.1050433172@saturn>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox