| From: | Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> |
|---|---|
| To: | Jim <shakahshakah(at)gmail(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: simple (?) join |
| Date: | 2009-09-28 13:43:53 |
| Message-ID: | 200909281443.53367.gary.stainburn@ringways.co.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Monday 28 September 2009 13:30:32 you wrote:
> SELECT o.*, ol.*
> FROM orders o
> LEFT JOIN (
> SELECT ol.o_id, MAX(ol_timestamp) AS maxts
> FROM orders_log ol
> GROUP BY 1
> ) max_olt
> ON max_olt.o_id=o.o_id
> LEFT JOIN orders_log ol
> ON ol.o_id=o.o_id
> AND ol.ol_timestamp=max_olt.maxts
> ;
Cheers Jim,
That worked.
Gary
--
Gary Stainburn
Gary's Haircut 700
Please visit http://www.justgiving.com/Gary-Stainburn/ to help me
raise money for Cancer Research - in return I'll have my head shaved
| From | Date | Subject | |
|---|---|---|---|
| Next Message | the6campbells | 2009-09-29 02:54:35 | Common table expression - parsing questions |
| Previous Message | David W Noon | 2009-09-28 11:27:16 | Re: simple (?) join |