Can I concatenate fields on the thame row?

  • Hi

    I have a records with fields named question1 thru question10

    for example if I query select * from mytable with startdate > 1/1/2010

    I may get

    StartDate Question1 Question2 Question3....

    1/1/2010 yes no no

    1/2/2010 no no no

    what I would like is a filed which would concatenate the fields with the value "no"

    similar to

    1/1/2010 yes no no Question2,Question3

    1/2/2010 no no no Question1,Question2,Question3

    Thanks

  • Actually I just tried

    case when (Question1 = N'No') then 'text here ' else '' end

    + case when (Question2 = N'No') then 'text here ' else '' end

    + case when (Question3 = N'No') then 'text here ' else '' end as result

    It works, but maybe something better ?

  • jbalbo (6/29/2015)


    Actually I just tried

    case when (Question1 = N'No') then 'text here ' else '' end

    + case when (Question2 = N'No') then 'text here ' else '' end

    + case when (Question3 = N'No') then 'text here ' else '' end as result

    It works, but maybe something better ?

    If this works for you then use it. I don't think there's a much better way to do it.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply