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 / honey
with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >1
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What does select 1 mean?
What is subreport?
What are the differences between INNER JOIN, LEFT JOIN and RIGHT JOIN in SQL Server?
what are the different types of replication you can set up in sql server? : Sql server database administration
How sql server enhances scalability of the database system?
What is federation member?
What is plan freezing?
Can you pass expressions to function parameters?
Write an sql query to sort a table according to the amounts in a row and find the second largest amount.
What does truncate do?
What is a cursor, index in sql?
What is the difference between Triggers and Stored Procedure?
What is default constraint?
Explain the purpose of indexes?
How to get a list of table columns using the "sp_columns" stored procedure in ms sql server?