pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedsum a subquery?
2+ messages / 2 participants
[nested] [flat]
* sum a subquery?
@ 2000-04-14 04:55 Graeme Merrall <gmerrall@email.com>
0 siblings, 1 reply; 2+ messages in thread
From: Graeme Merrall @ 2000-04-14 04:55 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: sum a subquery?
@ 2000-04-14 05:54 Patrik Kudo <kudo@partitur.se>
parent: Graeme Merrall <gmerrall@email.com>
0 siblings, 0 replies; 2+ messages in thread
From: Patrik Kudo @ 2000-04-14 05:54 UTC (permalink / raw)
To: Graeme Merrall <gmerrall@email.com>; +Cc: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-04-14 05:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-04-14 04:55 sum a subquery? Graeme Merrall <gmerrall@email.com>
2000-04-14 05:54 ` Patrik Kudo <kudo@partitur.se>
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