From gmerrall@email.com Fri Apr 14 04:48:59 2000 Received: from merlin.inspire.net.nz (merlin.inspire.net.nz [203.96.157.130]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA77811 for ; Fri, 14 Apr 2000 00:48:59 -0400 (EDT) (envelope-from gmerrall@email.com) Received: from home (james.inspire.net.nz [203.96.157.137] (may be forged)) by merlin.inspire.net.nz (8.9.3/8.9.3) with SMTP id QAA02449 for ; Fri, 14 Apr 2000 16:46:51 +1200 (NZST) Message-ID: <004001bfa5cd$b1d0e7c0$899d60cb@inspire.net.nz> Reply-To: "Graeme Merrall" From: "Graeme Merrall" To: Subject: sum a subquery? Date: Fri, 14 Apr 2000 16:55:45 +1200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_003D_01BFA632.46AA3A40" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Archive-Number: 200004/151 This is a multi-part message in MIME format. ------=_NextPart_000_003D_01BFA632.46AA3A40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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-s= elect to do this or what. I've a feeling I'm messing around in the right a= rea but can't quite get it together. Cheers, Graeme ------=_NextPart_000_003D_01BFA632.46AA3A40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dunno if this is the right way to ask a qu= estion=20 but...
I'm inheriting some data and need to perfo= rm a=20 query on it to sum a column of figures. The only problem I have to sum on t= he=20 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=20 possible to use a sub-select to do this or what. I've  a feeling I'm= =20 messing around in the right area but can't quite get it together.
 
Cheers,
 Graeme
------=_NextPart_000_003D_01BFA632.46AA3A40-- From kudo@partitur.se Fri Apr 14 05:55:00 2000 Received: from bastuba.partitur.se (bastuba.partitur.se [193.219.246.194]) by hub.org (8.9.3/8.9.3) with ESMTP id BAA21278 for ; Fri, 14 Apr 2000 01:55:00 -0400 (EDT) (envelope-from kudo@partitur.se) Received: from partitur.se (tb303.partitur.se [193.219.246.230]) by bastuba.partitur.se (8.8.8/8.8.8) with ESMTP id HAA29811; Fri, 14 Apr 2000 07:54:51 +0200 (CEST) (envelope-from kudo@partitur.se) Message-ID: <38F6B2AB.645B1997@partitur.se> Date: Fri, 14 Apr 2000 07:54:51 +0200 From: Patrik Kudo X-Mailer: Mozilla 4.72 [en] (X11; I; FreeBSD 4.0-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Graeme Merrall CC: pgsql-sql@postgresql.org Subject: Re: sum a subquery? References: <004001bfa5cd$b1d0e7c0$899d60cb@inspire.net.nz> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200004/153 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