Here is simple query based on query from Docs
WITH RECURSIVE T(N) AS (
SELECT 1
UNION ALL
SELECT N+1 FROM T WHERE N<10
)
SELECT N AS N1, N+0 as N2 FROM T;
Here is result:
N N2
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
Please note heading N that should be N1.
One more question. I'm trying query for fibonacci numbers based on
query for MS Sql Server http://progopedia.com/version/microsoft-sql-server-2005/
For query:
with fibonacci(a, b) as
(
select 1, 1
union all
select b, a+b from fibonacci where b < 1000000
)
SELECT a AS fib FROM fibonacci;
it shows
Feature not supported: "VARCHAR +"; SQL statement:
with fibonacci(a, b) as
(
select 1, 1
union all
select b, a+b from fibonacci where b < 1000000
)
SELECT a AS fib FROM fibonacci [50100-159]
[Error Code: 50100]
[SQL State: HYC00]
Though next two queries work:
with fibonacci(a, b) as
(
select 1, 1
union all
select b, cast(a AS INT)+cast(b AS INT) from fibonacci where b <
1000000
)
SELECT a AS fib FROM fibonacci;
with fibonacci(a, b) as
(
select 1, 1
union all
select b, 0+a+b from fibonacci where b < 1000000
)
SELECT a AS fib FROM fibonacci;
I believe first one should work too.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.