Reputation: 2544
Can I use multiple WITH-subqueries within one query?
;WITH x AS (
SELECT ...
),
WITH y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...
Upvotes: 1
Views: 88
Reputation: 79969
It is called common table expression, and yes, you can use multiple CTE's, use only one WITH
and remove the second with
like this:
WITH x AS (
SELECT ...
),y AS (
SELECT ...
)
SELECT * FROM z
INNER JOIN x ON ...
INNER JOIN y ON ...
Upvotes: 3