Re: sum a subquery?

From: Patrik Kudo <kudo(at)partitur(dot)se>
To: Graeme Merrall <gmerrall(at)email(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sum a subquery?
Date: 2000-04-14 05:54:51
Message-ID: 38F6B2AB.645B1997@partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I think what you want to do is the following:

SELECT sum(number_column), letter_column FROM table_name
GROUP BY letter_column;

Hope I got it right...

Regards,
Patrik Kudo

> Graeme Merrall wrote:
>
> Dunno if this is the right way to ask a question but...
> I'm inheriting some data and need to perform a query on it to sum a
> column of figures. The only problem I have to sum on the condition of
> the contents of another column.
> e.g.
>
> 12.23 I
> 23.45 P
> 56.67 I
> 11.11 P
>
> SO I need to sum all the I's and all the P's. Is it possible to use a
> sub-select to do this or what. I've a feeling I'm messing around in
> the right area but can't quite get it together.
>
> Cheers,
> Graeme

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2000-04-14 06:44:50 Re: Function xxxx() does no exist
Previous Message Graeme Merrall 2000-04-14 05:46:12 Doh! (HTML mail)