Re: - Mailing list pgsql-novice

From Tom Lane
Subject Re:
Date
Msg-id 4307.1138722490@sss.pgh.pa.us
Whole thread Raw
In response to ...  ("Gan Uesli Starling" <alias@starling.us>)
List pgsql-novice
"Gan Uesli Starling" <alias@starling.us> writes:
> I am trying to figure out how to winnow out in a single query (no
> intermediate
> tables) the most recent event for each sensor which has been 'Calibrated' or
> 'Repaired' not 'Damaged' afterwards.

I think you can probably do this with SELECT DISTINCT ON (look at the
"weather reports" example in the SELECT reference page).  DISTINCT ON
is nonstandard, but the bog-standard ways to do this involve messy,
inefficient sub-SELECT constructions.

            regards, tom lane

pgsql-novice by date:

Previous
From: Murat Tasan
Date:
Subject: function returning a setof a column type
Next
From: Tom Lane
Date:
Subject: Re: function returning a setof a column type