Interview Questions   Tutorials   Discussions   Programs   

Teradata - Write a single SQL to delete duplicate records from the a single table based on a column value? I need only Unique records at the end of the Query?




3214
views
asked mar September 20, 2014 06:38 AM  

Write a single SQL to delete duplicate records from the a single table based on a column value? I need only Unique records at the end of the Query?


           

1 Answers



 
answered By vishnoiprem   0  
Method:

If atleast one column is distinct, we can delete using

CT table as RESERVATION_IDS

as RESERVATION with no data

Insert into RESERVATION_IDS

Select
*
from con_reservation
qualify row_number() over (
partition by RESERVATION_IDS order by RESERVATION_IDS)=2

;

delete from RESERVATION

where RESERVATION_ID (select RESERVATION_IDS from RESERVATION_IDS)
;

Insert into RESERVATION
select * from RESERVATION_IDS;

Method2 

Create SET table RESERVATION_IDS
as RESERVATION_IDS with data;



rename table RESERVATION_IDS as RESERVATION_IDS_new
;
remane table RESERVATION_IDS as RESERVATION_IDS ;
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert