Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

WITH y AS (

    WITH x AS (

        SELECT * FROM MyTable

    )

    SELECT * FROM x

)

SELECT * FROM y

Does something like this work? I tried it earlier but I couldn't get it to work.

1 Answer

0 votes
by (40.4k points)

Try using common table expressions to reuse previous queries in subsequent ones. You need the form of the statement like this:

WITH x AS 

(

    SELECT * FROM MyTable

), 

y AS 

(

    SELECT * FROM x

)

SELECT * FROM y

Related questions

Browse Categories

...