I wonder if there is any way to generate Fibonacci numbers that beat in simplicity and efficiency this one I wrote:
WITH d (seq) AS
(SELECT LEVEL
on the simplicity side of things, the query can rely on the built in features (ITERATE ()
and ITERATION_NUMBER
) of MODEL
:
select * from dual
model
dimension by (0 seq)
measures (0 val)
rules iterate (195)
(
val[iteration_number] = val[iteration_number-1] + val[iteration_number-2],
val[2] = 1,
val[1] = 0,
val[0] = 0
)
;