Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is an inner join?

915


how you can configure a running aggregate in SSRS?

184


What are some of the pros and cons of not dropping the sql server builtinadministrators group? : sql server security

931


Can we call future method from trigger?

879


can a database be shrunk with users active? : Sql server administration

950


Does group by sort data?

846


How would we use distinct statement? What is its use?

1023


What do you understand by hotfixes and patches in sql server?

914


How can we improve performance by using SQL Server profiler?

984


How do use Having,Group by,Group function in SQL?

1692


Can an entity have two primary keys?

925


Which is the best place or learning center for MS SQL?????In Bangladesh?????

2018


how will add additional conditions in sql?

1013


What is the data type of time?

909


How to find the second highest salary of an employee?

1106