Is there a select function to add cols that are often null?

Forum for DBF Commander discussing.

Is there a select function to add cols that are often null?

Postby somethingsimil » Thu Jan 01, 2015 12:13 am

I have a complex query where I select and add a number of columns, which are sometimes null...

SELECT a+b+c (query is much much larger)

...sometimes "a" is null and it makes the whole result null even when b and c have value. Is there a function to add and ignore nulls? If I wrap each terms in nvl the query gets too long for command line use. :(
somethingsimil
 
Posts: 30
Joined: Tue Jul 08, 2014 6:05 pm

Re: Is there a select function to add cols that are often nu

Postby Admin » Thu Jan 01, 2015 11:18 am

The only function to handle NULL values is NVL(). Or, you can update NULLs before the summation as follows:

Code: Select all
UPDATE table1 SET col_name1=NVL(col_name1,0)
UPDATE table1 SET col_name2=NVL(col_name2,0)
...
Best regards,
Oleg Zhechkov
User avatar
Admin
Site Admin
 
Posts: 124
Joined: Wed Apr 21, 2010 7:27 pm


Return to DBF Commander Professional

Who is online

Users browsing this forum: No registered users and 5 guests

cron