Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Attempting to get Result as "%"
Mark C. Stock wrote:
> you'll need to use a CASE expression to convert a 0 divisor to 1 to avoide
> the ORA-01476
I see this a lot and I have never understood it, as it will return essentially random data, e.g.
20/2 will be equal to 10/0 which it obviously is not.
And what is the fear of null, if you have a null return it don't put some random value in there. I would argue that n/0 should be returned as null or 'NA'. In which case the select should simply be
select case when on_duty <> then
to_char(production / on_duty * 100) || '%'
end,
or
select case when on_duty <> then
to_char(production / on_duty * 100) || '%'
else
'NA'
end,
Received on Fri Feb 03 2006 - 07:05:33 CST