Re: Learning SQL: nested CTE and UNION - Mailing list pgsql-novice

From Jonatan Reiners
Subject Re: Learning SQL: nested CTE and UNION
Date
Msg-id F8300A1E9780480898B92103499BFA78@encc.de
Whole thread Raw
In response to Learning SQL: nested CTE and UNION  (Adam Mackler <adammackler@gmail.com>)
Responses Re: Learning SQL: nested CTE and UNION  (Adam Mackler <adammackler@gmail.com>)
List 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

pgsql-novice by date:

Previous
From: Adam Mackler
Date:
Subject: Learning SQL: nested CTE and UNION
Next
From: Adam Mackler
Date:
Subject: Re: Learning SQL: nested CTE and UNION