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 difference between oltp and olap?

580


How to disconnect from a sql server using mssql_close()?

591


What is wrong with sql server client libarary dll, ntwdblib.dll?

563


List out some of the requirements to set up a sql server failover cluster?

548


How to create a dml trigger using create trigger statements?

564






What are the types of lock supported by ?

614


Explain why variables called the most powerful component of ssis?

538


What is Cross Join and in which scenario do we use Cross Join?

576


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

588


How to configure odbc dsn with different port numbers?

565


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?

624


What are the joins in sql server? : sql server database administration

538


What is the purpose of data source?

518


What do you understand by integration services in sql server?

559


Name the different type of indexes in sql?

535