pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrik Kudo <kudo@partitur.se>
To: Graeme Merrall <gmerrall@email.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sum a subquery?
Date: Fri, 14 Apr 2000 07:54:51 +0200
Message-ID: <38F6B2AB.645B1997@partitur.se> (raw)
References: <004001bfa5cd$b1d0e7c0$899d60cb@inspire.net.nz>

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



view thread (2+ messages)

Message-ID: <38F6B2AB.645B1997@partitur.se>
Permalink:  ../38F6B2AB.645B1997@partitur.se/
Also on:    postgresql.org/message-id/38F6B2AB.645B1997@partitur.se

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: kudo@partitur.se, gmerrall@email.com
  Subject: Re: sum a subquery?
  In-Reply-To: <38F6B2AB.645B1997@partitur.se>
  References: <004001bfa5cd$b1d0e7c0$899d60cb@inspire.net.nz> <38F6B2AB.645B1997@partitur.se>

* 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