[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

issue with case statement

I have this code and am getting an error, can someone help me understandy why the error exists with both case statements but not individually?

select *,
CASE WHEN ([Planned_Event_Status] = 'ES' AND [Activity Stat Cd] = 'A') THEN 'Y'
CASE WHEN ((NOT ([Planned_Event_Status] LIKE 'ES')) AND [Activity Stat Cd] = 'O') THEN 'Y'
ELSE 'N' END AS [(GPSy - PLC Error)]


from PLC_GLOBAL_INFO_ES_GE_5YEARS


Error:

Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'CASE'.
0
Fairfield
Asked:
Fairfield
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
remove the second CASE. you only need CASE once in the beginning, from there, you repeat only the WHEN keyword
0
 
FairfieldAuthor Commented:
Duh.....go figure
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now