Re: Learning SQL: nested CTE and UNION

From: Jonatan Reiners <jreiners(at)encc(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Learning SQL: nested CTE and UNION
Date: 2012-07-31 13:57:40
Message-ID: F8300A1E9780480898B92103499BFA78@encc.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

I hope this gives you a clue.

This works:

WITH outmost AS (
SELECT 1
UNION (WITH innermost as (SELECT 2)
SELECT * FROM innermost
)UNION SELECT 3
)
SELECT * FROM outmost;

> But this does not work:
>
> WITH outmost AS (
> SELECT 1
> UNION (WITH innermost as (SELECT 2)
> SELECT * FROM innermost
> UNION SELECT 3)
> )
> SELECT * FROM outmost;
>
>
>

--
Jonatan Reiners

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2012-07-31 14:12:57 Re: [patch] libpq one-row-at-a-time API
Previous Message Adam Mackler 2012-07-31 13:49:27 Learning SQL: nested CTE and UNION

Browse pgsql-novice by date

  From Date Subject
Next Message Adam Mackler 2012-07-31 14:47:20 Re: Learning SQL: nested CTE and UNION
Previous Message Adam Mackler 2012-07-31 13:49:27 Learning SQL: nested CTE and UNION