if 3 duplicate records in table,i want to delete 2 alternating
duplicate records by keeping 1 duplicate and 1 original as it
is,how?
Answer Posted / sivam
sno sname salary
1 aaa 1000
1 aaa 1000
2 bbb 2000
2 bbb 2000
2 bbb 2000
1 aaa 1000
;with aa as
(
select sname,salary,ROW_NUMBER()over(partition by sno,sname,salary order by sno,sname,salary) as Nos from #testtable
)
delete from aa where Nos%2<>0
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain how does the report manager work in ssrs?
What is SQL Server?
What is ssrs?
Why is replication required on the sql server?
How to backup encryption key ?
What are sql dirty pages?
How to rename an existing table with the "sp_rename" stored procedure in ms sql server?
Difference between drill down and drill through report.
What do you mean by the term 'normalization'?
How to modify the underlying query of an existing view?
What is an identity?
How to write an inner join with the where clause in ms sql server?
How do database indexes work?
Explain raiserror in sql server?
How to defragment indexes with alter index ... Reorganize?