我有这个更新 SQL:
UPDATE o
SET HolidayPay = lob.AllowHolidayPay ,
AppreciationPay = lob.AllowAppreciationPay
FROM Orders AS o
INNER JOIN LineofBusiness AS lob ON o.LineofBusinessID = lob.LineofBusinessID
WHERE o.StatusID != 156 -- ALL ORDERS THAT ARE NOT CLOSED
AND o.TempOrDirect = 'T'
GO
我需要让 WHERE 子句不仅仅使用 statusID。需要发生的是如果 statusID = 156,那么它还需要检查 stageID 的值。因此,如果 statusID = 156,但 stageID = 6,那没关系。如果 statusID 仍然是 156 但 stageID 是任何其他值,则观察到 != 部分。
提前致谢!