Hi
How to update Duplicate Records only . i mention condition below.
Create Table emp1
(
Id int primary key identity(1,1),
Empname varchar(50),
EmpID int,
Empstatus int,
empcreateDate Datetime
)
insert into emp1 values('John',1,1,GETDATE())
insert into emp1 values('John',1,1,GETDATE())
insert into emp1 values('John',1,1,GETDATE())
insert into emp1 values('John wesly',2,1,GETDATE())
insert into emp1 values('John wesly',2,1,GETDATE())
insert into emp1 values('Johnsob',3,1,GETDATE())
insert into emp1 values('Johnsobwer',4,0,GETDATE())
insert into emp1 values('Felix',5,1,GETDATE())
insert into emp1 values('Felix',5,1,GETDATE())
insert into emp1 values('Felix',5,1,GETDATE())
insert into emp1 values('Felix',5,1,GETDATE())
insert into emp1 values('Felix',5,1,GETDATE())
insert into emp1 values('Felix',5,0,GETDATE())
insert into emp1 values('Felix',5,0,GETDATE())
SELECT * FROM EMP1
-- For Ex
-- How to Update empstatus =0 last Effect Record but same empid based on Date
1 John 1 1 2016-09-21 15:16:03.340
2 John 1 1 2016-09-21 15:16:10.167
3 John 1 1 2016-09-21 15:22:35.773
-- I need output this
1 John 1 1 2016-09-21 15:16:03.340
2 John 1 1 2016-09-21 15:16:10.167
3 John 1 0 2016-09-21 15:22:35.773
Mark as Answer if its helpful to you
Kumaraspcode2009@gmail.com