Connecting Tech Pros Worldwide Help | Site Map

Stringing together a CASE expression

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 29th, 2008, 06:55 PM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default Stringing together a CASE expression

I am converting some MS Access queries into sharepointe reporting services and I'm stuck.

I have a query in access that basically says:
Expand|Select|Wrap|Line Numbers
  1. IIF ([column1] = true, 'yes1, ') & IIF ([column2] = true, 'yes2, ') as Results
  2.  
Below are the results I would get.
Expand|Select|Wrap|Line Numbers
  1. UserID   Results
  2. User1    Yes1, 
  3. User2    Yes1, Yes2, 
  4. User3    Yes2, 
  5. User4    
  6. etc...
  7.  
Trying to translate that over to SQL is where I'm stuck. I thought about something like:
Expand|Select|Wrap|Line Numbers
  1. CASE WHEN column1 = true THEN 'yes1, ' + CASE WHEN column2 = true THEN 'yes2, ' ELSE 'no' END AS Results
  2.  
That isn't working. It appears that if the first criteria is met it uses it and then adds the else result to the end of it.
Expand|Select|Wrap|Line Numbers
  1. UserID   Results
  2. User1    yes1, no
  3. User2    yes1, no
  4. User3    
  5. User4    
  6.  
Is there something other then CASE that I should be using? Basically I want to evaluate multiple true/false fields and show all trues in one column separated by commas.

Last edited by Atli; August 30th, 2008 at 07:36 PM. Reason: Added [code] tags.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.