Re: [GENERAL] Calcuate percentage.

From: Sze Yuen Wong <swong_(at)yahoo(dot)com>
To: "K(dot)T(dot)" <kanet(at)calmarconsulting(dot)com>, pgsql-general(at)hub(dot)org
Subject: Re: [GENERAL] Calcuate percentage.
Date: 1999-03-09 15:10:27
Message-ID: 19990309151027.12960.rocketmail@send202.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Can I somehow get the total number of rows in
a function?

if so, then I can say:

select var1, count(*) / numRows() * 100 from table1 group by var1;

Sze Wong

---"K.T." wrote:
>
> select var1, count(*) from table1 group by var1;
>
> will get you the count of how many of each number there is...
>
> I think the only way is to get the max and manually loop thru the
rows and
> calc the percentage.
>
> -----Original Message-----
> From: Sze Yuen Wong <swong_(at)yahoo(dot)com>
> To: pgsql-general(at)hub(dot)org <pgsql-general(at)hub(dot)org>
> Date: Tuesday, March 09, 1999 9:48 AM
> Subject: [GENERAL] Calcuate percentage.
>
>
> >Hi,
> >
> > I need to calcuate the percentage from my table:
> >
> >var1
> >------
> >1
> >1
> >1
> >2
> >2
> >3
> >
> >Desire result:
> >
> >var1 | percentage
> >----------------------------
> >1 | 50%
> >2 | 33%
> >3 | 17%
> >
> >===============================
> >
> >Any clue?
> >
> >Please help.
> >
> >Sze Wong
> >
> >
> >
> >
> >
> >
> >_________________________________________________________
> >DO YOU YAHOO!?
> >Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
>
>
>

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas G. Lockhart 1999-03-09 15:20:14 Re: [INTERFACES] the last row in a table
Previous Message K.T. 1999-03-09 15:08:25 Re: [GENERAL] Calcuate percentage.