UPDATE Client SET NoProvince= CASE WHEN (SELECT COALESCE((SELECT TOP 1 Invoice.AddUser FROM Invoice WHERE Invoice.NoClient=Client.Numero AND Invoice.NoItem=23 ORDER BY Invoice.AI DESC),0))<>1 THEN AddUser ELSE 0 ENDBasically, I need to select the most recent record in the invoice table based on NoItem=23 condition. Then, based on the value collected, in this case Invoice.AddUser, I need to have a sub condition to only replace Client.NoProvince if Invoice.AddUser value is not 1.