How to update this situation Records
HiHow to update duplicate record only one
create table tiff1
(
id int primary key identity(1,1),
refid int,
refstatus int,
refdttm datetime
)
select * from Test.dbo.tiff1
-- I need update duplicate record but only latest datetime records only 1 records only need update for status
-- here 1001 like this
1 1001 1 2016-10-07 15:05:02.100
2 1001 1 2016-10-07 15:05:04.577
3 1001 1 2016-10-07 15:05:05.790
--here i need update like this output
--
1 1001 1 2016-10-07 15:05:02.100
2 1001 1 2016-10-07 15:05:04.577
3 1001 0 2016-10-07 15:05:05.790
-- for all duplicate records but my table rows more then 5000 thousand
--different differnet refid how to fixed this