Re: Select Question - Mailing list pgsql-general

From Richard Huxton
Subject Re: Select Question
Date
Msg-id 200402022043.00840.dev@archonet.com
Whole thread Raw
In response to Re: Select Question  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
List pgsql-general
On Monday 02 February 2004 19:38, Jeff Eckermann wrote:
> --- Martijn van Oosterhout <kleptog@svana.org> wrote:
> > See DISTINCT ON()
>
> Yes, for selecting.  For deleting, probably something
> like:
>
> delete from table t1 where exists (select 1 from table
> t2 where t2.code = t1.code and t2.date > t1.date);

Quick note that Jeff's solution doesn't handle the situation where you have
codes with the same date. You don't say whether this is possible or not. If
it is, you'll need to distinguish between rows based on some other column.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Adam.Bukla@interia.pl (Adam Bukla)
Date:
Subject: Re: Problem with API (libpq) - detailed error codes
Next
From: "Ben"
Date:
Subject: Re: Very slow query - why?