datatechcorp
asked on
MSSQL Sum w/NULL Column Values
HELLO!
I have a table called "POSTING" with the following values:
EVENT_NO AMT DROP LOAN
-------------------------- ---------- ---------- ---------- ---------
E-1000117 0.00 NULL NULL
E-1000117 668.49 -1500.00 NULL
E-1000117 393.80 NULL NULL
E-1000117 1309.00 NULL NULL
E-1000117 0.00 NULL NULL
E-1000117 0.00 NULL NULL
E-1000117 0.00 NULL NULL
What I need to achieve...is something like the following:
Select Sum(AMT - DROP + LOAN) as NET_DAILY_TOTAL
However, of course, since there are many 'NULL' values in the DROP and LOAN columns, this will yield a total of 'NULL'...which is erroneous and nonsense. Please let me know the correct Syntax to handle the 'NULL' values in the example above. Thank You!...Mark
I have a table called "POSTING" with the following values:
EVENT_NO AMT DROP LOAN
--------------------------
E-1000117 0.00 NULL NULL
E-1000117 668.49 -1500.00 NULL
E-1000117 393.80 NULL NULL
E-1000117 1309.00 NULL NULL
E-1000117 0.00 NULL NULL
E-1000117 0.00 NULL NULL
E-1000117 0.00 NULL NULL
What I need to achieve...is something like the following:
Select Sum(AMT - DROP + LOAN) as NET_DAILY_TOTAL
However, of course, since there are many 'NULL' values in the DROP and LOAN columns, this will yield a total of 'NULL'...which is erroneous and nonsense. Please let me know the correct Syntax to handle the 'NULL' values in the example above. Thank You!...Mark
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both *SO* much for responding! I truly appreciate it...this worked great!
Thanks!...Mark
Thanks!...Mark
SELECT SUM(AMT - ISNULL([DROP],0) + ISNULL(LOAN,0)) AS NET_DAILY_TOTAL