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 / arijit mandal

DELETE FROM Employee a
WHERE ROW_NUMBER() <>
( SELECT MIN( ROW_NUMBER() )
FROM Employee b
WHERE a.empname = b.empname
AND a.salary = b.salary)

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the stuff and how does it differ from the replace function?

1123


What is resultset concur_updatable?

1017


Can I delete event logs?

922


What are the extra roles available in msdb? : sql server security

1125


if no size is defined while creating the database, what size will the database have? : Sql server administration

1000


What is sql stored procedure?

1084


How to sort the query output with order by clauses in ms sql server?

1031


What are the essential components of sql server service broker?

1018


When would you use it?

989


Ms sql server index?

1060


When would you use a before or after trigger?

905


What are the advantages of using stored procedures in sql server?

1009


Does partitioning improve performance?

968


What is perspective, have you ever created perspective? : sql server analysis services, ssas

911


What is the difference between mysql and mysqli?

1189