pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: Jim <shakahshakah@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: simple (?) join
Date: Mon, 28 Sep 2009 14:43:53 +0100
Message-ID: <200909281443.53367.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <f7f8bfab-28aa-4b61-8094-b2b6e7ba6ab8@a6g2000vbp.googlegroups.com>
References: <200909241616.36933.gary.stainburn@ringways.co.uk>
	<200909281202.20768.gary.stainburn@ringways.co.uk>
	<f7f8bfab-28aa-4b61-8094-b2b6e7ba6ab8@a6g2000vbp.googlegroups.com>

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
 



view thread (25+ messages)

Message-ID: <200909281443.53367.gary.stainburn@ringways.co.uk>
Permalink:  ../200909281443.53367.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200909281443.53367.gary.stainburn@ringways.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gary.stainburn@ringways.co.uk, shakahshakah@gmail.com
  Subject: Re: simple (?) join
  In-Reply-To: <200909281443.53367.gary.stainburn@ringways.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox