with mytab(a, lvl) as
(
select 1 a, 1 lvl from dual
union all
select a*(lvl+1), lvl+1 from mytab where lvl < 10
)
select lvl, a fact from mytab
2. Power (ab)
with mytab(a, b, c) as
(
select 3 a, 5 b, 1 c from dual
union all
select a, b-1, c*a from mytab where b > 0
)
select a,5-b b, c pow from mytab
More Examples
- Recursive Subquery Factoring Examples: Fibonacci
- Recursive Subquery Factoring Examples: Employee Manager Hierarchy
Related Links
- SQL Interview Question Answers
- Oracle SQL Puzzles
- WITH Clause - subquery factoring clause
No comments:
Post a Comment