Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help needed

Re: SQL help needed

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: Sat, 21 Aug 1999 02:06:14 GMT
Message-ID: <37c60886.44404159@netnews.worldnet.att.net>


I think:

DELETE FROM t t1
WHERE t1.d <> (

	SELECT MAX(t2.d)
	FROM t t2
	WHERE t2.b=t1.b and t2.c=t1.c);

Test that before you run it for real.

Jonathan



jonathan_at_gennick.com
http://gennick.com
Brighten the Corner Where You Are

On 20 Aug 1999 13:53:20 GMT, "Peter Laursen" < ptl_at_edbgruppen.dk> wrote:

>create table t(
> a int primary key,
> b int,
> c date,
> d date)
>
>I need to make (b,c) unique but duplicates exist. I want to delete all
>duplicates but one, leaving the row where d is newest.
>That is if t(1,1,01-01-99, 01-01-99) and t(2,1,01-01-99, 12-12-99) both
>exist, I want to keep the second. btw the timepart of the dates does
>matter, not just the date part.
Received on Fri Aug 20 1999 - 21:06:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US