select *  from ExciseDetails where BRANCH+Code+convert(nvarchar(2),sno)
in (select  BRANCH+Code+convert(nvarchar(2),sno) from ExciseDetails
group by  BRANCH+Code+convert(nvarchar(2),sno)
having count( BRANCH+Code+convert(nvarchar(2),sno))>1)
order by  BRANCH+Code+convert(nvarchar(2),sno)




delete from ExciseDetails where RecordKey in
(select max(RecordKey)  from ExciseDetails where  BRANCH+Code+convert(nvarchar(2),sno)
in (select   BRANCH+Code+convert(nvarchar(2),sno) from ExciseDetails
group by  BRANCH+Code+convert(nvarchar(2),sno)
having count( BRANCH+Code+convert(nvarchar(2),sno))>1)
group by  BRANCH+Code+convert(nvarchar(2),sno)
) 



select * from ExciseDetails where RecordKey in
(select max(RecordKey)  from ExciseDetails where  BRANCH+Code+convert(nvarchar(2),sno)
in (select   BRANCH+Code+convert(nvarchar(2),sno) from ExciseDetails
group by  BRANCH+Code+convert(nvarchar(2),sno)
having count( BRANCH+Code+convert(nvarchar(2),sno))>1)
group by  BRANCH+Code+convert(nvarchar(2),sno)
and eccno =''
) 




