How to add 2 decimal columns when one of them may be null

Hi experts,

If I have two decimal columns in a table and I want to return the sum of the two columns added together as another column in my resultset, how do I do it when one of the columns 'may' be NULL?

(OPR.refund_product_value + OPR.refund_extra_value) AS refund_total_value

If one of the two values here is NULL, the result is also NULL.

Help appreciated.
Who is Participating?
Ephraim WangoyaCommented:

(ISNULL(OPR.refund_product_value, 0) + ISNULL(OPR.refund_extra_value, 0)) AS refund_total_value
SELECT COALESCE(table1.field1,0,table1.field1) + COALESCE(table1.field2,0,table1.field2)  as fieldname
FROM table1
jammy-d0dgerAuthor Commented:
Perfect, spot on.  Works a treat, thanks for that.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.