Can we use WITH for more than one nested query in SQL?


#1

Question

Can we use WITH for more than one nested query in SQL?

Answer

Yes, you can use WITH for more than one nested query. You can do so by listing each query using commas after the WITH.

For example,

WITH
query1 AS (SELECT column1 FROM table1 WHERE condition1),
query2 AS (SELECT column2 FROM table2 WHERE condition2)
…