Skip to content
Advertisement

SQL ARITHMETIC OPERATION

I am trying to get the sum of two rows using (+) operator in select. But when one column is null, the column for the SUM will also be null.

If 2019 have sales amount of 20,000 and 2020 with 0 or null, the TOTAL_SALES will also be NULL I am wondering if there is a way to make the TOTAL_SALES be 20,000 too.

Advertisement

Answer

Why don’t you use the conditional aggregation as follows:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement