Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

How to update the duplicate records in Teradata - response (3) by dnoeth

$
0
0

Hi Siddesh,
following sets the duplicate flag for all duplicate rows
UPDATE tab
SET dupflag = 1
WHERE (col1,col2,col3) IN
(SELECT col1,col2,col3 
 FROM tab
 GROUP BY 1,2,3
 HAVING COUNT(*) > 1
)

 

Of course those columns should be NOT NULL.

 

Depending on the percentage of duplicate rows it might be more efficient to the the calculation during an insert/select using an OLAP function:

 

CASE WHEN COUNT(*) OVER (PARTITION BY col1,col2,col3) > 1 THEN 1 ELSE 0 END

Dieter


Viewing all articles
Browse latest Browse all 27759

Trending Articles