Click here to Skip to main content
15,303,572 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to sum 2 columns, in both colums there are some NULL, if i sum these two columns for example col A, col B, if any one column has null , it gives my null, while it has to show other values which exist in other colums, like
SQL
SUM(A+B)
A=5, B = null, it has to show 5, but it gives me null, can anybody help me, thanks

What I have tried:

i have tried isnull, coalesce, but it does not give correct answer
Posted
Updated 5-Dec-21 0:00am
v2

1 solution

Not sure if I understand the question correctly but have you tried
SQL
SUM(COALESCE(A, 0) + COALESCE(B,0))
   
Comments
ali khan Dec2021 5-Dec-21 6:10am
   
many thanks for your help
Wendelius 5-Dec-21 6:19am
   
Glad it helped :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900