I have written the following SQL to retrieve all records in WEEK_PHASINGS where the shipment period is less than one week.
I then want to update the column PHASINGS in table WEEK_PHASINGS where this is true to 100
select WEEK_P.SKU_RATIO_ID,
SH.SHIP_START_DT,
SH.SHIP_END_DT,
datediff (wk, SH.SHIP_START_DT,SH.SHIP_END_DT )AS DATEDIFF_SHIP_ST_END
from SHIP_HIST SH
inner join WEEK_PHASINGS WEEK_P
on WEEK_P.PROMO_ID_REF = SH.PROMO_ID
where datediff (wk, SH.SHIP_START_DT,SH.SHIP_END_DT ) = 0
Open in new window
I then want to update the column PHASINGS in table WEEK_PHASINGS where this is true to 100
update WEEK_PHASINGS
set PHASING = 100
where PROMO_ID_REF in (
select WEEK_P.SKU_RATIO_ID,
SH.SHIP_START_DT,
SH.SHIP_END_DT,
datediff (wk, SH.SHIP_START_DT,SH.SHIP_END_DT )AS DATEDIFF_SHIP_ST_END
from SHIP_HIST SH
inner join WEEK_PHASINGS WEEK_P
on WEEK_P.PROMO_ID_REF = SH.PROMO_ID
where datediff (wk, SH.SHIP_START_DT,SH.SHIP_END_DT ) = 0);
Open in new window
Could I get some help with my update syntax/statement as it will not execute correctly. Thank you
try:
Open in new window