Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (2.6k points)

In a stored procedure (Oracle in my case), I want to add some values to an existing record. Problem is that both the existing value and the value to be added can be null. I only want the result to be NULL when both operands are null. If only one of them is null, I want the result to be the other operand. If both are non-null, I want the result to be "normal" addition.

1 Answer

0 votes
by (7.2k points)

You can use ISNULL for adding some null value, 

, so if you have 5 values

isnull(value1,0)+isnull(value2,0)+isnull(value3,0)+isnull(value4,0)

+isnull(value5,0)

 We have to use 0, where we get NULL value in it. otherwise its original value in SQL server.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...