Best DB2 SQL Queries to work on Duplicate Values

How to remove duplicates:

SELECT DISTINCT(Column_name) from test_table;

The above query selects all distinct values.

How to get only duplicate values:

SELECT COL1, COL2,COL3,COUNT(*)  FROM TEST_TABLE

WHERE PAN_ID >=10

GROUP BY COL1, COL2, COL3

HAVING COUNT(*) > 1;

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.