Re: Picking out the most recent row using a time stamp column

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Dave Crooke" <dcrooke(at)gmail(dot)com>, "Michael Glaesemann" <grzm(at)seespotcode(dot)net>
Cc: "pgsql-performance" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Picking out the most recent row using a time stamp column
Date: 2011-02-24 20:24:15
Message-ID: 4D666A0F020000250003AFCE@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Michael Glaesemann <grzm(at)seespotcode(dot)net> wrote:

> 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;

Dang! I forgot the DESC in my post! Thanks for showing the
*correct* version.

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dave Johansen 2011-02-24 20:51:53 Re: Pushing IN (subquery) down through UNION ALL?
Previous Message Michael Glaesemann 2011-02-24 20:21:49 Re: Picking out the most recent row using a time stamp column