Re: Picking out the most recent row using a time stamp column - Mailing list pgsql-performance

From Michael Glaesemann
Subject Re: Picking out the most recent row using a time stamp column
Date
Msg-id 08B3368E-E623-4E9C-83F5-AB05B471AF4C@seespotcode.net
Whole thread Raw
In response to Picking out the most recent row using a time stamp column  (Dave Crooke <dcrooke@gmail.com>)
Responses Re: Picking out the most recent row using a time stamp column  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-performance
On Feb 24, 2011, at 14:55, Dave Crooke wrote:

> Is there a more elegant way to write this, perhaps using PG-specific
> extensions?

SELECT DISTINCT ON (data.id_key)
       data.id_key, data.time_stamp, data.value
  FROM data
  ORDER BY data.id_key, data.time_stamp DESC;

Michael Glaesemann
grzm seespotcode net




pgsql-performance by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Picking out the most recent row using a time stamp column
Next
From: "Kevin Grittner"
Date:
Subject: Re: Picking out the most recent row using a time stamp column