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

Explain the properties of sub-query in sql server?

1000


What is the guest user account in sql server? What login is it mapped to it? : sql server security

1056


Can you always create a cache of a report?

172


Define master database?

1048


Can one drop a column from a table?

1008


What you can do to delete a table without the delete trigger firing?

960


What are types of scd? : sql server analysis services, ssas

1009


How exceptions can be handled in sql server programming?

1005


explain extended properties

979


What are the advantages of using stored procedures?

942


How important do you consider cursors or while loops for a transactional database?

958


Can the “if update (colname)” statement be used in a delete trigger?

981


explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

1049


What are rows and columns?

1014


Explain how to integrate the ssrs reports in application?

1004