On Dec 4, 2011, at 22:28, Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> wrote:
> Hi.
>
> Is here any way to combine WITH and WITH RECURSIVE into single query?
>
> Something like:
>
> WITH t AS (some complicated select to speed up recursive part),
> RECURSIVE r AS
> (
> ...
> UNION ALL
> ...
> )
>
> ?
>
> --
> Maxim Boguk
> Senior Postgresql DBA.
WITH RECURSIVE q1 As (), q2 AS () ...
Add RECURSIVE after the WITH; it then applies to any/all the CTEs.
Look at the specification (and description) in the SELECT documentation closely.
David J.