Skip to Content
author's profile photo Former Member
Former Member

Trying to add up fields in query.

Hi I have a few user defined fields that are numeric fields and I want to add them together in a query. The problem is that sometimes one of the fields is null because it's blank and it won't add them together if one is null. How can I make it treat null fields as 0's?

Here's a sample of the query:


In some cases T0.[U_FREIGHT_1] might be the only field with a value, in others all 6 could have a value and in others none of them may have a value.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on May 15, 2014 at 01:44 PM


    You nee to ISNULL function to get correct result.

    Follow below sample and same way change your query:

    SELECT isnull(T1.[U_F1],0) + isnull(T1.[U_F2],0) + isnull(T1.[U_F3],0) FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocNum] = [%0]

    Thanks & Regards,


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.