|
|
Archives of the TeradataForum
Message Posted: Thu, 19 Aug 2004 @ 18:52:42 GMT
Subj: | | Re: DELETE recommendations? |
|
From: | | Arnaud_Balat |
Hi TIA,
Below is a sql that would do something close from what you want I think:
delete from table
where (PK1, PK2) IN (
select A.PK1, A.PK2 from table A, table B
where A.PK1 = B.PK1
and A.PK2=B.PK2
and A.PK3 != B.PK3
group by A.PK1, A.PK2
having count(*) > 1)
In the example that you gave it would delete the two first rows, it would also delete a third one with similar PK1 and PK2 whatever the
value of PK3 if there was one, if this is what you want..
You can run the select SQL alone first in order to see what are the combination of PK1 And PK2 that will be deleted.
Arnaud
| |