From: Ragnar Hafstað <gnari@simnet.is>
To: Michael L. Hostbaek <mich@the-lab.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: select & group by
Date: Mon, 04 Apr 2005 10:59:15 +0000
Message-ID: <1112612355.19933.12.camel@localhost.localdomain> (raw)
In-Reply-To: <1112611630.19933.6.camel@localhost.localdomain>
References: <20050404101647.GJ23648@mich2.itxmarket.com>
<1112611630.19933.6.camel@localhost.localdomain>
On Mon, 2005-04-04 at 10:47 +0000, Ragnar Hafstað wrote:
> On Mon, 2005-04-04 at 12:16 +0200, Michael L. Hostbaek wrote:
> > [problem]
> [slightly broken solution]
I forgot a FROM clause, and you might want to add a
ORDER BY clause, if that is important:
select part,mfg,
sum(CASE WHEN eta is NULL then qty ELSE 0 END) as qty,
sum(CASE WHEN eta is NULL then 0 ELSE qty END) as "qty incoming",
max(price) as "highest price",
min(eta) as eta
from thetable
group by part,mfg
order by part,mfg;
gnari
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gnari@simnet.is, mich@the-lab.org
Subject: Re: select & group by
In-Reply-To: <1112612355.19933.12.camel@localhost.localdomain>
* 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