Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?

5923


Is it possible to update the views? If yes, how, if not, why?

1024


How to loop through returning rows?

1034


What is dirty read?

1080


Explain subquery and state its properties?

1040


What is the difference between createstatement and preparedstatement?

938


What is coalesce and check constraint in sql server?

1118


What are the differences between “row_number()”, “rank()” and “dense_rank()”?

1143


How to check status of stored procedure in sql server?

982


what is new philosophy for database devises for sql server 7.0? : Sql server database administration

1003


What are parameterized reports? What are cascading parameters in ssrs reports?

156


What is the sql profiler?

938


What types of replication are supported in sql server?

1063


Does sql server use java?

1067


What is indexing in sql server with example?

1000