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

Does partitioning improve performance?

1018


Mention the 3 ways to get a count of the number of records in a table.

1025


Difference between Inner vs outer joins?

985


Can you force a query to use a specific index?

988


Once setting replication, can you have distributor on sql server 2005, publisher of sql server 2008?

1007


What is policy based management (pbm)? : sql server database administration

1029


How you provide security to cube? : sql server analysis services, ssas

1008


Mention what are the core components of ssrs?

330


Is null vs coalesce?

927


Explain the difference between delete,drop and truncate in SQL Server?

1159


How to view the error log for any specific instance? : sql server database administration

1096


What is the bookmark lookup and rid lookup?

1034


How to create a view using data from another view?

994


What are the common performance issues in sql server?

971


How self join is different from outer join?

1175