Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help needed
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
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