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

Re: problem query ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Taylor <postgres(at)jtresponse(dot)co(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: problem query ...
Date: 2002-01-31 17:02:21
Message-ID: (view raw or whole thread)
Lists: pgsql-novice
John Taylor <postgres(at)jtresponse(dot)co(dot)uk> writes:
> I want to return 1 row for each id, that contains the maximum update
> value for that id, and the values for name and desc.

There's no simple way to do that in standard SQL.  However you can do
it easily with SELECT DISTINCT ON, if you don't mind using a nonstandard
construct.  See the "weather report" example on the SELECT reference

			regards, tom lane

In response to


pgsql-novice by date

Next:From: John TaylorDate: 2002-01-31 17:08:29
Subject: Re: problem query ...
Previous:From: Bob SavageDate: 2002-01-31 16:40:08
Subject: Re: column headers all in upper-case letters?

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