Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01476: Divisor ist Null persists in spite of NVL or DECODE

LPNOSep 29 2017 — edited Sep 29 2017

I have this nice query for daily SQL analyst's work:

select c.owner, c.table_name,t.num_rows, 

    c.num_distinct, c.num_nulls, c.Column_name,',' s

--,c.*

from dba_tab_Columns c, dba_tables t

where c.owner = t.owner and c.table_name = t.table_name 

and c.table_name = upper(:1) and num_distinct >1 order by column_id;

Now it like to expand it to calcualte the percentage or NULL-Columns in the table.  Now I'm a bit stuck with this:

Either this

select c.owner, c.table_name,t.num_rows, 

    decode (c.num_nulls,null, null, to_char(t.num_rows / c.num_nulls,'99.999' )) non_nulls,

    c.num_distinct, c.num_nulls, c.Column_name,',' s

--,c.*

from dba_tab_Columns c, dba_tables t

where c.owner = t.owner and c.table_name = t.table_name 

and c.table_name = upper(:1) and num_distinct >1 order by column_id;

or that

select c.owner, c.table_name,t.num_rows, 

   nvl2(c.num_nulls, null, to_char(t.num_rows / nvl(c.num_nulls,0.0001),'99.999' )) non_nulls,

    c.num_distinct, c.num_nulls, c.Column_name,',' s

--,c.*

from dba_tab_Columns c, dba_tables t

where c.owner = t.owner and c.table_name = t.table_name 

and c.table_name = upper(:1) and num_distinct >1 order by column_id;

both bring error message: [Error] Execution (19: 56): ORA-01476: Divisor ist Null

Can you please provide some help on this?

How to avoid the calculation to be evaluated, if the divisor is NULL?

This post has been answered by BrunoVroman on Sep 29 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2017
Added on Sep 29 2017
12 comments
1,327 views