Subject Re: Merge results of recursive CTE with results of non-recursive CTE
Author hvlad
--- In firebird-support@yahoogroups.com, Nols Smit wrote:
>
> Hi,
>
>
> Is it possible to merge results of a recursive CTE with the results of a non-recursive CTE?
>
> I seems one can not have one executable block of SQL containing both.
>
> Typically I use a non-recursive CTE to filter data for the main table, referencing many lookup tables. However, two of the lookup tables are tree-structures. If I filter data using only one tree-structure (as a lookup table) then a recursive CTE is easy to use but I can not figure out how to use a combination in one executeable block of SQL.

Not sure i understand you correctly, but... did you tried to create query with more that one CTE ? :)

I.e. something like

WITH RECIRSUVE
cte1 as (...), // 1st recursive cte
cte2 as (...), // 2nd recursive cte
cte3 as (...) // non-recursive cte

SELECT ...
FROM cte1 JOIN cte2 ON ... JOIN cte3 ON ...

Regards,
Vlad