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 are the basic functions for master, msdb, model, tempdb databases?
What are types of scd? : sql server analysis services, ssas
Why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it?
What the difference between UNION and UNIONALL?
What is user-defined multi-statement table-valued function?
Do you know what is replace and stuff function in sql server?
What is the difference between web edition and business edition?
what is the difference between Tabular and Matrix report?
How to send email from database?
Explain various data region available in ssrs with their use?
Can one drop a column from a table?
What do you mean by an execution plan? How would you view it?
What are group functions in query statements in ms sql server?
What are the different types of data sources in ssrs?
How to copy data from one table to another table?