| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | "Gan Uesli Starling" <alias(at)starling(dot)us> | 
| Cc: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: | 
| Date: | 2006-01-31 15:48:10 | 
| Message-ID: | 4307.1138722490@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
"Gan Uesli Starling" <alias(at)starling(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-01-31 18:53:10 | Re: function returning a setof a column type | 
| Previous Message | Gan Uesli Starling | 2006-01-31 15:10:28 |