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

Re: SQL Question - Almost, Not Quite...

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: operationsengineer1(at)yahoo(dot)com
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: SQL Question - Almost, Not Quite...
Date: 2006-05-25 21:56:46
Message-ID: 20060525215646.GA6020@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Thu, May 25, 2006 at 14:30:05 -0700,
  operationsengineer1(at)yahoo(dot)com wrote:
> 
> Bruno, no worries.  i didn't explain what i wanted too
> well.  i'm *only* interested in the last (latest
> timestamp) inspect_result for each inspect_id.

Then DISTINCT ON is the the simplest way to do this. You can ORDER BY
inspect_id DESC, timestamp DESC to get the last record for each inspect_id.
This is not standard SQL though.

In response to

pgsql-novice by date

Next:From: operationsengineer1Date: 2006-05-25 21:56:51
Subject: Re: SQL Question - S/B Good...
Previous:From: operationsengineer1Date: 2006-05-25 21:30:05
Subject: Re: SQL Question - Almost, Not Quite...

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