Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Posts
    46

    Unanswered: Need Help with Case Statements

    Hi guys,

    Can someone show me the DB2 structure for creating multiple CASE statments in the same query? I wrote this query, but I get syntax errors:

    SELECT RECIP_SSN_NBR,

    CASE WHEN BENEF_STAT_CD = 'AC' THEN 'ACTIVE' ELSE 'INACTIVE' END AS TEST,
    CASE WHEN BENEF_STAT_CD = 'DP THEN 'DROP' ELSE 'INACTIVE' END AS TEST2


    FROM DSNP.PR01_T_RECIP_SYS

    Thanks!

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    > CASE WHEN BENEF_STAT_CD = 'DP THEN 'DROP' ELSE 'INACTIVE' END AS TEST2
    You forgot a quotation mark after 'DP.

  3. #3
    Join Date
    Mar 2009
    Posts
    3
    CASE
    WHEN bool expression THEN 'result '
    WHEN another bool expression THEN 'another result '
    ELSE 'default result' END AS a_Field

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •