create table CityMaste
(
ID int identity(1,1),
City varchar(200),
State varchar(200)
)
insert into CityMaste (city,State) values ('New Delhi','Delhi')
insert into CityMaste (city,State) values ('New Delhi','Delhi')
insert into CityMaste (city,State) values ('Gurgaon','HR')
insert into CityMaste (city,State) values ('Noida','UP')
insert into CityMaste (city,State) values ('Noida','UP')
1st method
delete from CityMaste where ID not in ( select max(ID) from CityMaste group by city)
2nd method
delete FROM CityMaste WHERE CityMaste.%%physloc%% NOT IN (SELECT MIN(cm.%%physloc%%) FROM CityMaste cm GROUP BY cm.city)
Warm Regards,
AMARENDRA KUMAR AMAR
SSE
9990662544
amaren1982@gmail.com
Kundan64, if this helps please login to Mark As Answer. | Alert Moderator