I have a set of data that is a list of names and a list of values next to them. There is a 3rd column that is for an amended value. Basically I want to add the values together but if there is a value in the 3rd column I want to use that one instead of the real value.
SELECT
[name],
COALESCE(thirdColumn,SecondColumn) AS [Values]
FROM
YourTable;
SELECT
SUM(COALESCE(thirdColumn,SecondColumn)) AS SumOfValues
FROM
YourTable;
Yes - if the third column is NULL. COALESCE function goes down the argument list, starting at the first one. If the first one is not null, it picks that value. If that is null, it picks the second value, and so on.