| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: factorial
try this:
with factorial (level, n, f) as
( values(1, 1, 1)
union all
select level+1, n+1, f*(n+1)
from factorial
where level<10
Just wonder why use sql to do this kind of thing? Regards,
Fan Ruo Xin
Mikito Harakiri wrote:
> WITH
> factorial AS (
> select n+1, f*(n+1) from factorial
> union
> select 1, 1 from table(values(1,1)) )
> SELECT f FROM factorial
> WHERE n=5
>
> 1. Is this going to work?
> 2. If not why, and what would be the correct recursive definition?
Received on Sat Jan 05 2002 - 23:06:19 CST
![]() |
![]() |