Combing two CASE Statement

  • Im doing a view in sql server 2005 and I want combine two CASE statement into one column. How do I do that. Do I put a + sign between the two CASE statement?

    thanks

  • I suppose you want to show some column value depending on some condition and also some other column value depending on some condition combined with the 1st column.

    e.g.

    SELECT someIdNumber,

    (CASE price WHEN 100 THEN somecolumn ELSE 'None' END) +

    (CASE netAmount WHEN 100 THEN someothercolumn ELSE 'All' END)

    AS SomeExpression

    FROM yourtable

    It can be done using multiple CASE statements and combining them with a +. But you must be sure that both the data types of these CASE statement outputs are same.

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

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