how do you count the duplicate records in a table

Answer Posted / babu

Try this,
select col1,count(col1) from tab1
group by col1 having count(col1)>1;

If you want to delete these duplicate entries, use:
delete from tab1 where col1 in (select a.col1 from
(select col1,count(col1) from tab1
group by col1 having count(col1)>1) a);

Is This Answer Correct ?    18 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by stored procedures? How do we use it?

712


What is a nested table in word?

705


Can we write dml inside a function in sql server?

675


What is null in pl/sql?

812


Does user triggers have entry for trigger with compilation errors?

794






Are stored procedures compiled?

678


What is duration in sql profiler trace?

774


what is online transaction processing (oltp)? : Sql dba

713


What is a system versioned table?

702


What are the uses of merge?

896


What is the difference between rename and alias?

972


how can we destroy the session, how can we unset the variable of a session? : Sql dba

729


What has stored procedures in sql and how we can use it?

765


What is your daily office routine?

1987


when MSQL8.0 is in market

1774