Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 19 Aug 2004 @ 18:52:42 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023