SQL Server : How to treat nulls as zeros

sql-server

Solution

Using the isNull function, such as

isnull(s1.ordervalue,0)

If the value is null, it uses the alternative value you provided as the second value.

Problem

Here is an example of what I'm trying to do: ``` Select S1.Name as S1Name, S1.Itemcontent as S1ItemContent, ... S2.Name as S2Name, S2.Name as S2ItemContent, **(S1.OrderValue * 1000*1000 + S2.OrderValue*1000 + S3.OrderValue) as OrderValue** From (joining s1, s2 and s3 on a particular value) Order by OrderValue ``` When S1.OrderValue, S2.OrderValue or S3.OrderValue is a null, then OrderValue becomes a null as well. I want SQL Server to treat nulls as a 0 in this case. How can i do this?

Original source