The Task is to fetch the top most value from the same identical other column values:
For Ex:
Create table #MyTemp(Name varchar(10), Value varchar(10))
insert into #MyTemp(Name, Value) values('Awais', '100')
insert into #MyTemp(Name, Value) values('Raghu', '500')
insert into #MyTemp(Name, Value) values('Awais', '110')
insert into #MyTemp(Name, Value) values('Raghu', '550')
Code:
select * from #MyTemp
select *
FROM #MyTemp
WHERE Value NOT IN
(
SELECT MAX(Value)
FROM #MyTemp
GROUP BY Name)