Skip site navigation (1) Skip section navigation (2)

For each record in SELECT

From: Luis Magaña <joe666(at)gnovus(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>,PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>,PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: For each record in SELECT
Date: 2003-01-31 21:21:17
Message-ID: 1044048077.1380.3.camel@kerberus (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-novicepgsql-sql

I have a question here:

I have a table with this fields:


now I have to write a query that retrieves the sum of the amount from
the minimum month to the maximum month registered for each diferent

Of course there are cases when a particular description has not record
for all the months in that period.  I mean, suppouse you have this

month	description	amount
June	description1	100	
July	description1	500
August	description1	600
June	description2	300
August	description2	400

how you write a query that outputs something like this:

            	June	July	August
description1 |	100	500	600
description2 |	300	0	400

My problem is for the 0 value.

I hope I've explained clearly my question.

Thanks for the help.

Best Regards.

Luis Magaña.
Gnovus Networks & Software.


pgsql-novice by date

Next:From: Oliver ElphickDate: 2003-01-31 22:01:47
Subject: Re: where is
Previous:From: Robert MosherDate: 2003-01-31 20:04:36
Subject: serial field starting at specific value

pgsql-general by date

Next:From: Robert TreatDate: 2003-01-31 21:29:40
Subject: Re: using pgcrypt
Previous:From: pilslDate: 2003-01-31 21:20:52
Subject: SQL-question (JOIN)

pgsql-sql by date

Next:From: Keary SuskaDate: 2003-02-01 01:28:34
Subject: Re: For each record in SELECT
Previous:From: Joe ConwayDate: 2003-01-31 19:32:59
Subject: Re: Postgres MD5 Function

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group