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 are the basic functions for master, msdb, model, tempdb databases?

1049


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

1019


Why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it?

891


What the difference between UNION and UNIONALL?

1045


What is user-defined multi-statement table-valued function?

1073


Do you know what is replace and stuff function in sql server?

1023


What is the difference between web edition and business edition?

111


what is the difference between Tabular and Matrix report?

173


How to send email from database?

1018


Explain various data region available in ssrs with their use?

939


Can one drop a column from a table?

1024


What do you mean by an execution plan? How would you view it?

919


What are group functions in query statements in ms sql server?

1013


What are the different types of data sources in ssrs?

196


How to copy data from one table to another table?

1000