Hi,
I need to update a column from the table when the datekey and tranchannel key matches, and as i am using sum i cannot directly do it i am using a subquery like this
UPDATE EDW.Planning.TEDW_F_TRANSACTION_CHANNEL_OPS_GOAL
SETOPS_GOAL
=
(
SelectSUM ( TEDW_F_STORE_OPS_GOAL.OPS_GOAL)
From EDW.Planning.TEDW_F_STORE_OPS_GOAL
INNER JOIN
EDW.Calendar.TEDW_D_DATE_TYPE_1
ON TEDW_D_DATE_TYPE_1.DATE_KEY = TEDW_F_STORE_OPS_GOAL.DATE_KEY
cross join
EDW.Utility.TEDW_J_PROCESS_DATE
WHERE TEDW_F_TRANSACTION_CHANNEL_OPS_GOAL.DATE_KEY=TEDW_D_DATE_TYPE_1.DATE_KEY
ANDTEDW_F_TRANSACTION_CHANNEL_OPS_GOAL.TRANSACTION_CHANNEL_KEY= TEDW_F_STORE_OPS_GOAL.TRANSACTION_CHANNEL_KEY
AND TEDW_F_STORE_OPS_GOAL.OPS_GOAL IS NOT NULL
)
But if i run this one i get an error saying
Cannot insert the value NULL into column 'OPS_GOAL', table 'EDW.Planning.TEDW_F_TRANSACTION_CHANNEL_OPS_GOAL'; column does not allow nulls. UPDATE fails.
I got this errror so i included NOTNULL in the where clause but still i get the same.
Any Suggestions please?
Thanks.