我可以在一个查询中使用多个WITH子查询吗?
;WITH x AS (
SELECT ...
),
WITH y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...
答案 0 :(得分:3)
它被称为common table expression,是的,您可以使用多个CTE,只使用一个WITH
并删除第二个with
,如下所示:
WITH x AS (
SELECT ...
),y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...