I am building an application that uses a SQL statement to sum three columns. Below is a sample table:
Table1
column1 column2 column3
NULL 30.00 NULL
60.00 NULL NULL
NULL 10.00 NULL
NULL NULL 15.00
I want to sum column1, column2, and column3 into one statement. I want the result to be 115.00 (30.00 + 60.00 + 10.00 + 15.00). The table can have data in one of the three columns, but never in any two.
This is what I have so far:
SELECT ISNULL(sum(column1),ISNULL(sum(column2),sum(column3)) as amount FROM Table1
The result is something not remotely close.