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

Re: Bringing other columns along with a GROUP BY clause

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Rob Richardson" <Rob(dot)Richardson(at)rad-con(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Bringing other columns along with a GROUP BY clause
Date: 2009-02-05 23:10:35
Message-ID: 87skmslbtg.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-general
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> I have a feeling that it could also be done via the "window functions"
> feature due to be introduced in 8.4, but I'm not entirely sure how.
> Anybody feeling handy with those?

There may be a better way but something like 

select * from (select *, rank() over (partition by charge order by coldspot_time desc) as r) where r = 1

?


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's 24x7 Postgres support!

In response to

pgsql-general by date

Next:From: Kusuma PabbaDate: 2009-02-06 05:27:45
Subject: small doubt
Previous:From: Erik JonesDate: 2009-02-05 23:05:24
Subject: Re: Pet Peeves?

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