Case Statement In SQL

SELECT SomeColumn1 =

(

  SELECT

    CASE

      WHEN SomeColumn3 IS NULL THEN ISNULL(SomeColumn3,)

      ELSE ISNULL(SomeColumn4,)

    END

  FROM SomeTable2 WHERE SomeColumn5 = @SomeParameter2

)

FROM SomeTable1

WHERE SomeColumn2 = @SomeParameter1

Advertisements