UPDATE MANU_EXECUTION SET IsDeleted=1, UpdateBy='ZJJ', IsOffline='1' WHERE Id in (
SELECT ME.Id
FROM MANU_EXECUTION ME
JOIN (
SELECT SFC, MIN(CreateOn) AS MaxCreateOn
FROM MANU_EXECUTION
WHERE CreateOn > '2023-07-01'
AND IsDeleted = 0 AND Status = 0
AND WorkOrderId = 'A49583FF-1EBB-11EE-A0F8-005056BF5922'
GROUP BY SFC
HAVING COUNT(*) > 1
) AS Subquery
ON ME.SFC = Subquery.SFC AND ME.CreateOn = Subquery.MaxCreateOn
WHERE ME.CreateOn > '2023-07-01'
AND ME.IsDeleted = 0 AND ME.Status = 0
AND ME.WorkOrderId = 'A49583FF-1EBB-11EE-A0F8-005056BF5922')