Problem with null

  • Hello!!!

    It might be easy (for u) but i'm stuck on this, i have an sproc where i calculate totals, my problem is that when i have a null column i need to assign 1 to that column to keep running the operations. (eg. )

    I need to calculate a simple total

    Price * Qty

    but if qty is null it must perform the multiplication like this:

    price * 1

    How can i do that ????? i'd tryed CASE, WHILE and IF and i can not get result i need.

    I really can't find a way to do it. Please if some one can enlight me to solve this i'll really appreciate.

    Thanks in advance

    Estuardo

     

    Manifest plainness,Embrace simplicity,Reduce selfishness,Have few desires.
    Lao-t'ze.

  • You are looking for IsNull which validates a column or variable to see if null, if not the use the value otherwise assign given value.

     

    Price * IsNull(Qty ,1)

  • Use ISNULL function.

    Check in BOL por use.

  •  

    Thank you both for your kind help. I did not know about that function.

    Works great!!!

    Best regards

    Estuardo

    Manifest plainness,Embrace simplicity,Reduce selfishness,Have few desires.
    Lao-t'ze.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply