ORA-01476: "divisor is equal to zero" for SQL query (Oracle 10g)
It all depends on whether you want to calculate a value if it would result in an infinite value or not. You can either ignore these particular instances and calculate on the remainder as Gordon's answer suggests with:
case when value2 <> 0 then value3 / value2 * 100 end
Alternatively, if want to ignore them you can use NULLIF()
to change the value to NULL and not calculate anything:
value3 / nullif(value2, 0) * 100
I do not understand your contention that this being a calculated column causes an issue. If it's a virtual column then your table would never have created, as specified in the documentation a virtual column cannot refer to another by name.
If it's not a virtual column then you can do this in a select statement as normal.
In your code, where you have:
select value3/value2*100 as value4
You should have:
select (case when value2 <> 0 then value3/value2*100 end) as value4
Given your question:
select value1, value2, value3, (case when value2 is not null then value3 / value2 * 100 end) as value4from (select value1, value2, (value1 - value2) as value3 from . . . )