All. I have the following code.
with filDelta as(select a.* from delta a
Where a.Pdelta>0
And a.oldprice between 0.0001 and 10000
and a.new_closeD between 0.0001 and 10000
),
Incr as(
select a.Symbol, log(a.oldprice,a.New_closeD) increase
From filDelta a
)
Select a.symbol
from Incr a
Where a.increase>=1.3459
However, it return me the error on the line where log() is located. Error is
ORA-01428: parameter'0' out of range 01428. 00000 - "argument '%s' is out of range"
But in my with clause, I already filter the value, why is that please?
With some data that simulates the problem , it looks like Oracle optimiser is rewriting the query in a way that pushes the predicate to a different level, meaning your filters are being applied after it's calculated the log. You could avoid that with the /* no_push_pred */
hint.
But you could also trap the condition in the same level before calling log:
with filDelta as(
select a.* from delta a
where a.Pdelta>0
and a.oldprice between 0.0001 and 10000
and a.new_closeD between 0.0001 and 10000
),
Incr as(
select a.Symbol,
case when a.New_closeD <= 0 then null
else log(a.oldprice,a.New_closeD) end increase
From filDelta a
)
Select a.symbol
from Incr a
where a.increase>=1.3459;
Or with fewer levels of CTE:
with filDelta as(
select a.*
from delta a
where a.Pdelta>0
and a.oldprice between 0.0001 and 10000
and a.new_closeD between 0.0001 and 10000
)
select a.Symbol
from filDelta a
where case when a.New_closeD <= 0 then null
else log(a.oldprice,a.New_closeD) end >=1.3459;
[SQL Fiddle](http://sqlfiddle.com/#!4/85ac0/10).
Or without a CTE at all:
select a.Symbol
from delta a
where a.Pdelta>0
and a.oldprice between 0.0001 and 10000
and a.new_closeD between 0.0001 and 10000
and case when a.New_closeD <= 0 then null
else log(a.oldprice,a.New_closeD) end >=1.3459;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.