If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Need Help with Case Statements

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-06-09, 09:58
rockdave35 rockdave35 is offline
Registered User
 
Join Date: Jan 2009
Posts: 43
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!
Reply With Quote
  #2 (permalink)  
Old 03-06-09, 11:23
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
> CASE WHEN BENEF_STAT_CD = 'DP THEN 'DROP' ELSE 'INACTIVE' END AS TEST2
You forgot a quotation mark after 'DP.
Reply With Quote
  #3 (permalink)  
Old 03-10-09, 17:38
philmee95 philmee95 is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On