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 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 is log shipping?

0 Answers  


What are the different subsets of sql?

0 Answers  


What is a trigger what are the advantages of trigger?

0 Answers  


How do I find the size of a sql server database?

0 Answers  


Give a example to search fr a string in all stored procedure in sql server.

0 Answers  


Can we add a cpu to sql server?

0 Answers  


What are the types of lock supported by ?

0 Answers   HCL,


What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM table

17 Answers   HP,


what is Archive old data?

1 Answers  


What is merge?

0 Answers  


What is star, snowflake and star flake schema? : sql server analysis services, ssas

0 Answers  


How would you choose between a clustered and a non-clustered index?

0 Answers  


Categories