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

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading