我可以在一个查询中使用多个 WITH 子查询吗?
;WITH x AS (
SELECT ...
),
WITH y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...
我可以在一个查询中使用多个 WITH 子查询吗?
;WITH x AS (
SELECT ...
),
WITH y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...
它被称为公用表表达式,是的,您可以使用多个 CTE,只使用一个WITH
并删除第二个with
,如下所示:
WITH x AS (
SELECT ...
),y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...