I have 2 tables with roughly the same columns.
I want to update the Status column of table Orders depending on whether the sum of ExecSignedAmount from table FilledOrders equals Orders.TargetPosition
But this UPDATE statement does not seem to recognise TargetPosition:
UPDATE [FX_PROD].[dbo].[tblOrders]
SET [Status] = (IF ((SELECT SUM([ExecSignedAmount])
FROM [FX_PROD].[dbo].[tblFilledOrders]
WHERE [OrderID] = 2) = [FX_PROD].[dbo].[tblOrders].[TargetPosition]) 'YES' ELSE 'NO')
WHERE [OrderID] = 2;
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire