UPDATE OPTIMUM_REBATE
SET RetailTarget = 930330.73,
ElectronicsTarget = 178446.89
WHERE CUST_ID = 1359709
UPDATE OPTIMUM_REBATE
SET Platinum = (
CASE
WHEN ot1.Program = 'PLAT' THEN 1
ELSE NULL
END),
Ambassador = (
CASE
WHEN ot1.Program = 'AMB' THEN 1
ELSE NULL
END)
FROM OPTIMUM_REBATE or1, (SELECT
lcc.CUST_ACCOUNT_ID,
ot.Program
FROM OptimumRebateTemp2 ot
LEFT OUTER JOIN LU_CUSTOMER lcc
ON lcc.CUSTOMER_NAME = ot.CUSTOMER_NAME) ot1
WHERE or1.CUST_ID = ot1.CUST_ACCOUNT_ID
UPDATE DimTransactionByMonth SET MonthDay =(
CASE DimTransactionByMonth.Month
WHEN 'December' THEN CAST(DimTransactionByMonth.Year + '-12-01' AS DATETIME2)
WHEN 'January' THEN CAST(DimTransactionByMonth.Year + '-01-01' AS DATETIME2)
WHEN 'February' THEN CAST(DimTransactionByMonth.Year + '-02-01' AS DATETIME2)
WHEN 'Feuary' THEN CAST(DimTransactionByMonth.Year + '-02-01' AS DATETIME2)
WHEN 'March' THEN CAST(DimTransactionByMonth.Year + '-03-01' AS DATETIME2)
WHEN 'April' THEN CAST(DimTransactionByMonth.Year + '-04-01' AS DATETIME2)
WHEN 'May' THEN CAST(DimTransactionByMonth.Year + '-05-01' AS DATETIME2)
WHEN 'June' THEN CAST(DimTransactionByMonth.Year + '-06-01' AS DATETIME2)
WHEN 'July' THEN CAST(DimTransactionByMonth.Year + '-07-01' AS DATETIME2)
WHEN 'August' THEN CAST(DimTransactionByMonth.Year + '-08-01' AS DATETIME2)
WHEN 'September' THEN CAST(DimTransactionByMonth.Year + '-09-01' AS DATETIME2)
WHEN 'October' THEN CAST(DimTransactionByMonth.Year + '-10-01' AS DATETIME2)
WHEN 'November' THEN CAST(DimTransactionByMonth.Year + '-11-01' AS DATETIME2)
--ELSE
END)
UPDATE OPTIMUM_REBATE
SET RetailTarget = ot1.Retail, ElectronicsTarget = ot1.FMS
FROM
OPTIMUM_REBATE or1
,(
SELECT lcc.CUST_ACCOUNT_ID, ot.Retail,ot.FMS FROM OptimumRebateTemp2 ot
LEFT OUTER JOIN LU_CUSTOMER lcc
ON lcc.CUSTOMER_NAME = ot.Customer_name) ot1
WHERE or1.CUST_ID = ot1.CUST_ACCOUNT_ID
UPDATE Optimum_Rebate_Periods
SET PeriodStart = '4.1.2014',
PeriodEnd = '4.1.2015'
WHERE ID = 2
UPDATE or1
SET or1.RetailTarget = ot.[2015 Retail Base Target],
or1.ElectronicsTarget = ot.[2015 FMS Base Target]
from
OPTIMUM_REBATE or1
inner JOIN
OptimumTemp ot
ON
ot.CUSTOMER_NAME = or1.CUSTOMER_NAME