Please give me queries for the following
1. To get the count of duplicate records.
2. A query to delete the duplicate records.
Answer Posted / meher
1. To get the duplicate records.
Use group by clause to the column on which you want to
check the duplicates records.
syntax:
select column_name, count(*) from table_name group by
column_name having count(*) >1
2. To delete the duplicate records.
syntax:
delete from table_name where rowid in (select max(rowid)
from table_name group by column_name having count(*)>1 )
This will work.
Please let me know in case of any issues.
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
What is an inner join?
how you can configure a running aggregate in SSRS?
What are some of the pros and cons of not dropping the sql server builtinadministrators group? : sql server security
Can we call future method from trigger?
can a database be shrunk with users active? : Sql server administration
Does group by sort data?
How would we use distinct statement? What is its use?
What do you understand by hotfixes and patches in sql server?
How can we improve performance by using SQL Server profiler?
How do use Having,Group by,Group function in SQL?
Can an entity have two primary keys?
Which is the best place or learning center for MS SQL?????In Bangladesh?????
how will add additional conditions in sql?
What is the data type of time?
How to find the second highest salary of an employee?