By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table STPDLV_ENTRY_TABLE (STP_UDF9 varchar(50)
, DLV_FLOW_XX int
, TS_TIME_LONG int)
insert into STPDLV_ENTRY_TABLE values ('bla', 3741539, 1)
1 rows affected
insert into STPDLV_ENTRY_TABLE values ('bla', 4044126, 2)
1 rows affected
insert into STPDLV_ENTRY_TABLE values ('bla', 5555555, 3)
1 rows affected
update (select *
from STPDLV_ENTRY_TABLE a
inner join (select DLV_FLOW_XX
, max(TS_TIME_LONG) AS MaxDateTime
from STPDLV_ENTRY_TABLE
group by DLV_FLOW_XX) b
on a.DLV_FLOW_XX = b.DLV_FLOW_XX
and a.TS_TIME_LONG = b.MaxDateTime
and a.DLV_FLOW_XX in (3741539,4044126,3741551)
and a.STP_UDF9 !='Posted') Test
set test.STP_UDF9 = 'Posted';
2 rows affected
select * from STPDLV_ENTRY_TABLE;
STP_UDF9 | DLV_FLOW_XX | TS_TIME_LONG |
---|---|---|
Posted | 3741539 | 1 |
Posted | 4044126 | 2 |
bla | 5555555 | 3 |