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...

Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500

Output should be

A 200
B 300
C 400
D 500

Answer Posted / sumathy

Execute the following query for each duplicate value.

1.Delete duplicate of empname='A'

delete top(select count(*)-1 from employee where
empname='A') from employee where empname='A'

2.Delete duplicate of empname='D'

delete top(select count(*)-1 from employee where
empname='D') from employee where empname='D'

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens when converting big values to numeric data types?

1226


Can you please explain the difference between function and stored procedure?

1046


How to retrieve error messages using odbc_errormsg()?

1106


Explain ms sql server reporting services vs crystal reports?

975


what stored procedure would you use to view lock information? : Sql server administration

1022


What is the use of builtinadministrators group in sql server? : sql server security

1106


What is RMS migrations?

2191


What is a ddl statement?

962


How do I find the sql server version?

1080


Name few of the dcl commands in sql?

1053


What is the server name in sql server?

1066


What is the maximum size per database for sql server express?

1103


how can you attach more than 20 ldf files in sql server

2050


How to find the version of sql server? : sql server database administration

1164


What is merge?

1069