if 3 duplicate records in a table,i want to delete 2 duplicate
records by keeping 1 as it is,how?



if 3 duplicate records in a table,i want to delete 2 duplicate records by keeping 1 as it is,how?..

Answer / venkat

if u r table like this
sno sname fee
1 a 1000
1 a 1000
2 b 1000
2 b 1000
3 c 1000
3 c 1000
--- write this
with duplicatecte
as
(select row_number()over(partition by sno,sname order by fee
)as rnum from students )
delete from dupcte where rnum>1

---run this query
select * from students
--out put is
1 a 1000
2 b 1000
3 c 1000

this is correct

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL Server Interview Questions

what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration

0 Answers  


How to test a dml trigger in ms sql server?

0 Answers  


in the physical file layout, where should the transaction log be stored in relation to the data file?

0 Answers  


what is the difference between count(*) and count(1) ?

0 Answers   MCN Solutions,


Define union, union all, minus, intersect?

0 Answers  






1. Tell me your daily activities 2. If sql server installation fails at time installation what will do 3. Where does the sql server installation log details are stored 4. After the installation what will you do for memory configuration 5. What is the difference between SQL max maximum memory and AWE memory 6. How will you configure AWE memory 7. How will setup an email alert for the backup job 8. After the SQL installation what are the jobs will you configure 9. What does –g mean in the sql startup parameter 10. What is the difference between Bulked log and Full recovery model 11. What is the difference between mirroring and log shipping 12. What are the steps to be followed before in-place up gradation 13. After installing the patch the sql server does not start and application team tells to rollback the changes .In this scenario what will you do

0 Answers   CSC, IBM,


how do u do Performance tunning ?

1 Answers   Infodat Technologies, Satyam,


Why use “in” clause in sql server?

0 Answers  


What are temporal tables in sql server 2016?

0 Answers  


What are the extra roles available in msdb? : sql server security

0 Answers  


What is the difference between dataadapter and datareader?

0 Answers  


Can we drop user if user mapped to any logins

1 Answers  


Categories