SQL Tip: Add two columns together in select statement

The Problem: I have a Cost A and a Cost B. I need to add them together and display them as Cost C in my SQL select statement. Sometime both Cost A and Cost B are null.

The Solution: SELECT  CostA, CostB, IsNull(CostA, 0) + IsNull(CostB, 0) As CostC. Without the IsNull, the columns were not adding together.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: