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

Do you know what is sql service broker?

0 Answers  


How do you delete duplicate records in sql server?

0 Answers  


Difference Between varchar and nvarchar datatype?

3 Answers   Satyam,


What is 1nf normalization form?

0 Answers  


How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?

3 Answers   HCL,


What are the restrictions while creating batches in sql server?

0 Answers  


How do you rename a table in sql server?

0 Answers  


What is raid and what are different types of raid levels?

0 Answers  


How to use values from other tables in update statements in ms sql server?

0 Answers  


What is scheduled job and how to create it?

0 Answers  


How to write stored procedure to update the data in 10 tables

4 Answers  


What is self join in sql server joins?

0 Answers  


Categories