Here is my query:
SELECT (contract_value + amendment_value) AS total_value
FROM contracts
ORDER BY total_value DESC
When I run it, the result for each row is NULL. Why is that so?
Each row has either a contract_value or an amendment_value, but not both. Where there is no value, it is NULL. Could that be the problem? (I could not find anything in the documentation to suggest it). If so, how do I get around it?
COALESCE(contract_value, amendment_value)will return whichever is non-NULL