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

Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query

3 Answers   RND Soft, Wipro,


What are logical database components? : SQL Server Architecture

0 Answers  


How much is a sql server license?

0 Answers  


What is view in sql?

0 Answers  


What are the requirements to use odbc connections in php scripts?

0 Answers  






What is a ddl statement?

0 Answers  


can you anybody tell me the how can you restore the master database. while migraion(one server to onther server)?

1 Answers  


How to invoke a trigger on demand?

0 Answers  


How to list all field names in the result set using mssql_field_name()?

0 Answers  


Is it true that rules do not apply to data already existing in a database at the time the rule is created?

0 Answers  


Define full outer join in sql server joins?

0 Answers  


Do you know what are acid properties of transaction?

0 Answers  


Categories