Skip to content
Advertisement

SQL minus 2 columns – with null values

I have this table (made from a SQL query):

Row 1 Row 2 
2     1    
3     NULL 

And I want to minus the 2 columns, so I just select like this:

Select Row1 - Row2
From table

But then I get this result:

1
NULL

instead of:

1
3

How can I make it possible to get the last result?

Advertisement

Answer

Please try:

SELECT ISNULL([Row 1], 0) - ISNULL([Row 2], 0) from YourTable

For more Information visit ISNULL

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