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 the use of @@spid?

0 Answers  


How many instances per computer are there in sql server 2000?

0 Answers  


Where the sql logs gets stored? : sql server database administration

0 Answers  


What is wide table?

0 Answers  


What is the difference between a Application Server and a Database

3 Answers   Oracle,


What are points to remember while using the fillfactor argument?

0 Answers  


What is the difference between a local and a global variable?

5 Answers  


What are the different types of replication? How are they used?

3 Answers  


What is the difference between a Local temporary table and a Global temporary table? How is each one used?

2 Answers   HCL,


How to implement service broker?

0 Answers  


What is the most common trace flags used with sql server?

0 Answers  


How will you find out if there are expensive SQL statements running or not?

0 Answers   Atos Origin,


Categories