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 the difference between upgrade and migration in sql server?
how many bits ip address consist of? : Sql server database administration
What do you understand by coalesce in sql server?
How to use old values to define new values in update statements in ms sql server?
What number aggregate functions are accessible there in sql?
What do you mean by sql server agent?
What are the system database in sql server 2005?
When is the use of update_statistics command?
How to list all tables in the database using odbc_tables()?
What are subqueries in sql server? Explain its properties.
How to backup SQL Server Reporting Services ?
Explain hostprotectionattribute in sql server 2005?
What are triggers in ms sql server?
What do you mean by acid?
Issues related in upgrading SQL Server 2000 to 2005 / 2008