How to compute Fibonacci sequence in SQL

Inspired and simplified from a set of slides on using RDBMS for storing, managing, and querying graphs:

with recursive fib(i,j) as (
    select 0,1
    union all
    select j, i+j from fib where j<1000
)
select i from fib

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.