Re: Best way to get the latest revision from a table

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Nikolas Everett" <nik9000(at)gmail(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Best way to get the latest revision from a table
Date: 2011-01-14 22:30:49
Message-ID: 4D307A390200002500039613@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Nikolas Everett <nik9000(at)gmail(dot)com> wrote:

> Am I missing something or is this really the best way to do this in
8.3?

How about this?:

SELECT y.*
from (select a, max(revision) as revision
from test where a between 2 and 200
group by a) x
join test y using (a, revision);

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Nikolas Everett 2011-01-14 22:40:08 Re: Best way to get the latest revision from a table
Previous Message Chris Browne 2011-01-14 21:19:42 Re: "COPY TO stdout" statements occurrence in log files