Re: select & group by

From: "Michael L(dot) Hostbaek" <mich(at)the-lab(dot)org>
To: Ragnar Hafstað <gnari(at)simnet(dot)is>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: select & group by
Date: 2005-04-04 12:23:34
Message-ID: 20050404122334.GM23648@mich2.itxmarket.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message lucas 2005-04-04 13:01:02 Chield Serial
Previous Message Ragnar Hafstað 2005-04-04 10:59:15 Re: select & group by