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

Re: Bringing other columns along with a GROUP BY clause

From: "Rob Richardson" <Rob(dot)Richardson(at)rad-con(dot)com>
To: "Sam Mason" <sam(at)samason(dot)me(dot)uk>,<pgsql-general(at)postgresql(dot)org>
Subject: Re: Bringing other columns along with a GROUP BY clause
Date: 2009-02-05 21:14:02
Message-ID: 04A6DB42D2BA534FAC77B90562A6A03DC57493@server.rad-con.local (view raw or flat)
Thread:
Lists: pgsql-general
Sam,

Great!  I had no idea DISTINCT ON existed.  That made it much simpler.
Here's what I used:

select distinct on (inventory.charge) coil_id, inventory.charge,
heating_coldspot_time_reached
from inventory
inner join charge on charge.charge = inventory.charge 
where base_type = '3' and heating_coldspot_time_reached > 0 and
inventory.status = 'Done' and inventory.charge >= 1000
order by charge, heating_coldspot_time_reached desc

And thanks for the tip about E-mail.  I thought that if I hit the Reply
button and then changed the subject line, it would be the same as
sending a new message to the same destination.  In this case, I had to
change the destination also, so it looked like a brand new message.  I
didn't know I was bringing along old baggage behind the scenes.

Thanks very much!

RobR

In response to

pgsql-general by date

Next:From: Rob RichardsonDate: 2009-02-05 21:31:40
Subject: Re: Bringing other columns along with a GROUP BY clause
Previous:From: Tom LaneDate: 2009-02-05 21:12:24
Subject: Re: Bringing other columns along with a GROUP BY clause

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