pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: justin <justin@emproshunts.com>
To: David W Noon <dwnoon@ntlworld.com>
To: pgsql-sql@postgresql.org
Subject: Re: simple (?) join
Date: Sat, 26 Sep 2009 16:15:37 -0400
Message-ID: <4ABE7669.50001@emproshunts.com> (raw)
In-Reply-To: <20090926205349.5fa284f1@dwnoon.ntlworld.com>
References: <200909241616.36933.gary.stainburn@ringways.co.uk>
	<20090924194629.44bc236f@dwnoon.ntlworld.com>
	<4ABBD34B.9080600@emproshunts.com>
	<20090924222106.23a5c1f3@dwnoon.ntlworld.com>
	<4ABE6360.20205@emproshunts.com>
	<20090926205349.5fa284f1@dwnoon.ntlworld.com>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
David W Noon wrote:
<blockquote cite="mid:20090926205349.5fa284f1@dwnoon.ntlworld.com"
 type="cite">
  <pre wrap="">On Sat, 26 Sep 2009 14:54:24 -0400, justin wrote about Re: [SQL] simple
(?) join:

[snip]
  </pre>
  <blockquote type="cite">
    <pre wrap="">Quoting Gary
"How can I select all from orders and the last (latest) entry from the 
orders_log?"
    </pre>
  </blockquote>
  <pre wrap=""><!---->
In that case, a simple Cartesian product will do:

SELECT o.*, maxi.ts
FROM orders AS o,
(SELECT MAX(ol_timestamp) AS ts FROM orders_log) AS maxi;

Since the cardinality of the subquery "maxi" is 1, it will give a result
set with cardinality of the complete orders table.

I don't understand why anybody would want to do that. [De gustibus ... ]
  </pre>
</blockquote>
<br>
Guessing here <br>
<br>
&nbsp;Answer to return the last time someone either viewed or edited the
order.<br>
<br>
This is a very common audit requirement to track who what, when and why
something happened.&nbsp; <br>
</body>
</html>



view thread (25+ messages)  latest in thread

Message-ID: <4ABE7669.50001@emproshunts.com>
Permalink:  ../4ABE7669.50001@emproshunts.com/
Also on:    postgresql.org/message-id/4ABE7669.50001@emproshunts.com

 · 

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: justin@emproshunts.com, dwnoon@ntlworld.com
  Subject: Re: simple (?) join
  In-Reply-To: <4ABE7669.50001@emproshunts.com>

* 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