I have a SQL table that consists of columns A, B and C. I am trying to construct a view consisting of all columns (i.e. A, B, C) and a computed column. This computed column has the following logic:
If B is blank or null then
NewColumn = A + ' - ' C
else
NewColumn = A + ' - ' + B
I am just wondering how the SQL statement should look like...
SELECT
CASE B
WHEN IS NULL A+C
ELSE A+B
END CASE AS 'myComputeColumns',
COLUMN_A,
COLUMN_B,
COLUMN_C
FROM YOUR_TABLE or VIEWS
|||Thanks for your help...
No comments:
Post a Comment