SQLTeam.com | Weblogs | Forums

How to concatnate 3 case statements


#1

,CASE WHEN CSF.MY_FLAG = 1 THEN ''V''
ELSE '' ''
END AS M_FLAG

,CASE WHEN CSF.YOUR_FLAG = 1 THEN ''D''
ELSE '' ''
END AS Y_FLAG

,CASE WHEN CSF.DAD_FLAG = 1 THEN ''P''
ELSE '' ''
END AS POP_FLAG

I would like this output V+D+P

I haven't had any luck and I keep seeing you can't concat more than 2. Is that correct. I am SQL novice still. Any help would be much appreciated.


#2

How did you try to concatenate?
CASE WHEN CSF.MY_FLAG = 1 THEN 'V' ELSE '' END + CASE WHEN CSF.YOUR_FLAG = 1 THEN 'D' ELSE '' END + CASE WHEN CSF.DAD_FLAG = 1 THEN 'P' ELSE '' END AS COMBINED_FLAG