pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik G. Burrows <eburrows@erikburrows.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL problem: bank account
Date: 02 Jun 2003 09:58:39 -0700
Message-ID: <1054573119.13212.41.camel@griffin.jedi-group.com> (raw)
In-Reply-To: <7888.1054561357@sss.pgh.pa.us>
References: <1054531815.13212.27.camel@griffin.jedi-group.com>
	<7888.1054561357@sss.pgh.pa.us>


This is the solution I was looking for! 20 seconds to compile the whole
list.

Thanks everyone for your help, I very much appreciate it. Even though
this is kind of 'hackey' being that it's non-standard SQL, it keeps the
database from having to to 40,000 selects, as would have to do with any
correlated sub-select statement.

Thanks!

> "Erik G. Burrows" <eburrows@erikburrows.com> writes:
> > I need to get the most recent transaction for each customer. I need only
> > the transaction ID, but the entire row would be best.
> 
> If you don't mind a not-standard-SQL solution, the SELECT DISTINCT ON
> construct is designed for this sort of thing.  See the "weather report"
> example in the SELECT reference page.
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/docs/faqs/FAQ.html
-- 
Erik G. Burrows - KG6HEA                   www.erikburrows.com
PGP Key: http://www.erikburrows.com/egb@erikburrows.com.pgpkey



view thread (9+ messages)

Message-ID: <1054573119.13212.41.camel@griffin.jedi-group.com>
Permalink:  ../1054573119.13212.41.camel@griffin.jedi-group.com/
Also on:    postgresql.org/message-id/1054573119.13212.41.camel@griffin.jedi-group.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: eburrows@erikburrows.com, tgl@sss.pgh.pa.us
  Subject: Re: SQL problem: bank account
  In-Reply-To: <1054573119.13212.41.camel@griffin.jedi-group.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