RosettaCodeData/Task/Loops-Do-while/DuckDB/loops-do-while.duckdb

17 lines
493 B
Plaintext

create or replace function do_while(init) as table (
with recursive cte as (
select init+1 as value -- Increment unconditionally
union all -- Loop
select value+1 as value -- Each time through the loop, add 1 to the value then print it.
from cte
where value % 6 != 0 -- "while value mod 6 is not equal to 0"
)
from cte order by value
);
# The task
from do_while(0);
# Also check that the loop executes at least once.
from do_while(-1);