select null value into 0(zero)

Hi,

can i know how to use a select statement to show the null value record to 0

my select statement is like this.

select orderqty - deliveryqty as outstandqty from Ordertable where orderdate > dateadd(mm, -1, getdate())

so in some case the deliveryqty will be null value due to some reason. can i able to make the value to 0 so the orderqty can -0 to get a value for outstandqty

regads

terence chua




Answer this question

select null value into 0(zero)

  • leungant

    Terence Chua wrote:

    select orderqty - deliveryqty as outstandqty from Ordertable where orderdate > dateadd(mm, -1, getdate())

    Use coalesce or isnull

    something like:

    select orderqty - coalesce(deliveryqty,0)



  • cchandru1974

    Thanks Louis Davidson - SQL Server MVP and EISA,

    both of the answer also can function. thanks a lot.



  • BJW


    Hi
    can you try this

    select orderqty - isnull(deliveryqty,0) as outstandqty from Ordertable where orderdate > dateadd(mm, -1, getdate())




  • select null value into 0(zero)