How to use multiple WITH statements in one PostgreSQL query?

前端 未结 2 1827
遥遥无期
遥遥无期 2020-12-04 18:40

I would like to \"declare\" what are effectively multiple TEMP tables using the WITH statement. The query I am trying to execute is along the lines of:

WITH         


        
2条回答
  •  自闭症患者
    2020-12-04 19:18

    You can also chain your results using WITH statement. Eg:

    WITH tab1 as (Your SQL statement),
    tab2 as ( SELECT ... FROM tab1 WHERE your filter),
    tab3 as ( SELECT ... FROM tab2 WHERE your filter)
    SELECT * FROM tab3;
    

提交回复
热议问题