DEV Community

Discussion on: Write a function that shows off something unique or interesting about the language you're using

Collapse
 
scottishross profile image
Ross Henderson • Edited

It isn't that difficult to generate the Fibonacci Spiral through Oracle SQL :)

with FIBONACCI (i, FIBO, PREV) as 
(
   select 
      1 i,
      0 FIBO,
      cast( null as number ) PREV 
   from 
      DUAL
   union all
   select 
      f1.i + 1  i,
      f1.FIBO + nvl(f1.PREV,1) FIBO,
      f1.FIBO PREV
   from 
      FIBONACCI f1
   where 
      f1.i < 20
)

select 
   FIBO
from 
   FIBONACCI
order by 
   i;