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 / devender kumar
This query is for sql server 2005 and higher version of sql
server. It will not run on older versions.
with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >3
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is an execution plan? How would you view the execution plan?
What is the server name for sql management studio?
What is the standby server?
Why we should not use triggers?
Explain “row_number()” in sql server with an example?
Can I save my report as html, excel or word? : sql server management studio
What is sql server management studio? : sql server management studio
How can sql server instances be hidden? : sql server security
What are the 10 characteristics of data quality?
What are the filtered indexes?
Can you name some of the dml commands in sql?
Explain what is sql server english query?
1.what are diff types of joins , and explain diff between cross join and full outer join 2.diff types of views 3. Diff types of index 4. What is diff b/w stores procedure and function procedure 5.diff between double and int in SQL 6.diff between char and varchar in SQL. 7.Oracle or SQL whice you will preferred and why.
What is oltp (online transaction processing)?
How do I make a resultset scrollable?