I'm much more familiar with VBA and less so with T-SQL.
Does the following code make sense? If a ‘WHEN’ statement evaluates as true, are the following WHEN statements skipped?
update CPI_Temp Set [ID_OWAM] =
CASE
WHEN [Orig_wam]< 24 THEN '01Y'
WHEN [Orig_wam]< 48 THEN '03Y'
WHEN [Orig_wam]< 72 THEN '05Y'
WHEN [Orig_wam]< 102 THEN '07Y'
WHEN [Orig_wam]< 150 THEN '10Y'
else
'15Y'
END Where PAY_TYPE = 'B';
The following code won’t compile, because it won’t let you use the “<” sign. I'd rather use CASE [Orig_wam] if possible ...
update CPI_Temp Set [ID_OWAM] =
CASE [Orig_wam]
WHEN < 24 THEN '01Y'
WHEN < 48 THEN '03Y'
WHEN < 72 THEN '05Y'
WHEN < 102 THEN '07Y'
WHEN < 150 THEN '10Y'
else
'15Y'
END Where PAY_TYPE = 'B';
Does the following code make sense? If a ‘WHEN’ statement evaluates as true, are the following WHEN statements skipped?
update CPI_Temp Set [ID_OWAM] =
CASE
WHEN [Orig_wam]< 24 THEN '01Y'
WHEN [Orig_wam]< 48 THEN '03Y'
WHEN [Orig_wam]< 72 THEN '05Y'
WHEN [Orig_wam]< 102 THEN '07Y'
WHEN [Orig_wam]< 150 THEN '10Y'
else
'15Y'
END Where PAY_TYPE = 'B';
The following code won’t compile, because it won’t let you use the “<” sign. I'd rather use CASE [Orig_wam] if possible ...
update CPI_Temp Set [ID_OWAM] =
CASE [Orig_wam]
WHEN < 24 THEN '01Y'
WHEN < 48 THEN '03Y'
WHEN < 72 THEN '05Y'
WHEN < 102 THEN '07Y'
WHEN < 150 THEN '10Y'
else
'15Y'
END Where PAY_TYPE = 'B';