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
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