Sokrates on Oracle

Archive for August, 2012

select the scale of a number

Posted by Matthias Rogel on 10. August 2012

with qs as
(
select
round(
dbms_random.value(-20, 20),
dbms_random.value(1, 15)
) q
from dual
connect by level<=10
)
select
qs.q,
case
when qs.q = floor(qs.q) then
0
when qs.q is null then null
else
(
select max(level)
from dual
connect by round(qs.q, level - 1) != qs.q
)
end as "scale(q)"
from qs
Advertisements

Posted in sql | Leave a Comment »