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
What is difference between oltp and olap?
How to disconnect from a sql server using mssql_close()?
What is wrong with sql server client libarary dll, ntwdblib.dll?
List out some of the requirements to set up a sql server failover cluster?
How to create a dml trigger using create trigger statements?
What are the types of lock supported by ?
Explain why variables called the most powerful component of ssis?
What is Cross Join and in which scenario do we use Cross Join?
What is the guest user account in sql server? What login is it mapped to it? : sql server security
How to configure odbc dsn with different port numbers?
While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?
What are the joins in sql server? : sql server database administration
What is the purpose of data source?
What do you understand by integration services in sql server?
Name the different type of indexes in sql?