Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 29th, 2008, 07: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 08:36 PM. Reason: Added [code] tags.
Reply
Reply

Bookmarks

Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles