Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me how to find duplicate records in SQL?

1 Answer

0 votes
by (119k points)

The following is the query to find the duplicate records in SQL:

SELECT col_1, col_2,…….

              COUNT (col)

FROM table_name

GROUP BY col_1, col_2,……

HAVING COUNT(*) > 1;

First, Group by clause groups the records by values of the col_1, col_2,… and after that Count()  returns the number of occurrences of each group. Later, Having clause filters the duplicate groups that have the count more than 1.

If you want to learn writing SQL queries, I recommend this SQL tutorial blog by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 27, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked May 7, 2020 in SQL by Sudhir_1997 (55.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...