From: Michael L. Hostbaek <mich@the-lab.org>
To: Ragnar Hafstað <gnari@simnet.is>
Cc: pgsql-sql@postgresql.org
Subject: Re: select & group by
Date: Mon, 4 Apr 2005 14:23:34 +0200
Message-ID: <20050404122334.GM23648@mich2.itxmarket.com> (raw)
In-Reply-To: <1112612355.19933.12.camel@localhost.localdomain>
References: <20050404101647.GJ23648@mich2.itxmarket.com>
<1112611630.19933.6.camel@localhost.localdomain>
<1112612355.19933.12.camel@localhost.localdomain>
Ragnar Hafstað (gnari) writes:
> 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;
Thanks, this works brilliantlty !
/mich
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: mich@the-lab.org, gnari@simnet.is
Subject: Re: select & group by
In-Reply-To: <20050404122334.GM23648@mich2.itxmarket.com>
* 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