SQL Query to Remove, get Only Duplicates

There are scenarios where you need to remove duplicates and you need to get only duplicates. Below examples ideally good for your project purpose.

SQL Query: How to remove duplicates:

SELECT DISTINCT(Column_name) 
from test_table;

The above query selects all distinct values.

SQL Query: How to get only duplicate values (or) You Can Use This Query to Verify Duplicates Exists

SELECT COL1, COL2,COL3,COUNT(*)  
FROM TEST_TABLE
WHERE PAN_ID >=10
GROUP BY COL1, COL2, COL3
HAVING COUNT(*) > 1;

Related Posts

Author: Srini

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