How we can use CTE in subquery in sql server?

后端 未结 3 1813
梦如初夏
梦如初夏 2020-12-15 03:05

How we can use CTE in subquery in sql server?

like ..

select id (i want to use CTE here), name from table_name

3条回答
  •  独厮守ぢ
    2020-12-15 03:37

    It doesn't work:

    select id (I want to use CTE here), name from table_name
    

    It's not possible to use CTE in sub queries.

    You can realize it as a work around:

    CREATE VIEW MyCTEView AS ..here comes your CTE-Statement.
    

    Then you are able to do this:

    select id (select id from MyCTEView), name from table_name
    

提交回复
热议问题