create or replace function fib_to(n) as table ( with recursive fib(e,f) as ( select 1, 1 union all select e+f,e from fib where e <= n) select f from fib order by f ); from fib_to(55);