I’m getting an error on my case expression. I just want to evaluate one condition, and return the proper statement. But I keep getting a syntax error near “as”.
Here’s what I have:
left outer join (
SELECT wbs1, wbs2, wbs3
, case
when (ProgramAffiliation = magrann.[programAffiliation_AEP/COHesh2010]())
then '[AEP] as ''AEP1'''
else [AEP Base] as 'AEP1'
end
, [AEP:Non-Compliant Mechanical Ventilation] as 'AEP2'
, [AEP - Non Energy Star AC ($90 deduction)] as 'AEP3'
, [AEP: Bonus] as 'AEP4'
Your
CASESyntax is wrong. You have a column name enclosed in single quotes and you have the alias in two places (both wrong):So your
CASEshould be:The alias goes after the
ENDin aCASEexpression.