Re: select & group by - Mailing list pgsql-sql

From Ragnar Hafstað
Subject Re: select & group by
Date
Msg-id 1112612355.19933.12.camel@localhost.localdomain
Whole thread Raw
In response to Re: select & group by  (Ragnar Hafstað <gnari@simnet.is>)
Responses Re: select & group by  ("Michael L. Hostbaek" <mich@the-lab.org>)
List pgsql-sql
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
qtyEND) as "qty incoming",      max(price) as "highest price",      min(eta) as eta
 
from thetable
group by part,mfg
order by part,mfg;

gnari




pgsql-sql by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: select & group by
Next
From: "Michael L. Hostbaek"
Date:
Subject: Re: select & group by