xcoder
xcoder

Reputation: 1436

Consecutive WITH clauses

In Postgres sql, is it possible to have consecutive WITH statements? e.g.

WITH t1 AS (
   ...some select statement
)

WITH t2 AS (
   ...select from t1
)

SELECT * FROM t2;

I have tried the above and it does;t seem to be working?

Upvotes: 0

Views: 649

Answers (1)

klin
klin

Reputation: 121834

Use:

WITH t1 AS (
   ...some select statement
),

t2 AS (
   ...select from t1
)

SELECT FROM t2; 

Upvotes: 3

Related Questions