Re: Percentage of Total Occurances

From: Adam Sherman <adam(at)tritus(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Cc: mallah(at)trade-india(dot)com
Subject: Re: Percentage of Total Occurances
Date: 2003-04-16 04:38:33
Message-ID: 71610000.1050467913@saturn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 04/16/03 01:11:08 +0530 mallah(at)trade-india(dot)com wrote:

>
>
> well if everything in a single query is that imp u may do this subselect:
>
> select answer_id , 1.0*count(*) / (select count(*) from polls where
> poll_id = ?) from polls where poll_id = ? group by answer_id ;
>
> and if u need to trim the trailing digits after decimal
> do to_char(value , '99.99')
>
> since u have not provided any sample data i cann't test it.

Thanks for your help, this was simpler than I thought.

A.

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message pginfo 2003-04-16 04:43:34 Re: changing column size and type.
Previous Message Brad Hilton 2003-04-16 00:00:22 Re: reversion? Recursion question