连续的WITH子句

时间:2016-01-22 00:44:10

标签: sql postgresql with-statement

在Postgres sql中,是否可以连续使用WITH语句? e.g。

WITH t1 AS (
   ...some select statement
)

WITH t2 AS (
   ...select from t1
)

SELECT * FROM t2;

我已经尝试了上述内容但确实有效;似乎正在发挥作用?

1 个答案:

答案 0 :(得分:3)

使用:

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

t2 AS (
   ...select from t1
)

SELECT FROM t2;