How to re-use one CTE in another CTE in jOOQ

后端 未结 1 1469
梦毁少年i
梦毁少年i 2021-01-14 23:59

In jOOQ am re-using a CTE in a later CTE. I am trying to summarise student completion records by year and school. I am using jOOQ 3.11.2 and postgres 9.4.

I have wor

1条回答
  •  有刺的猬
    2021-01-15 00:37

    Just like in your plain SQL version of your query, your cteCounts should not have a with(cteOne) clause:

    WITH 
      cteOne (columns...) AS (select...),
      cteCounts (columns...) AS (select referencing cteOne, no "with cteOne" here...)
    SELECT ...
    FROM ...
    

    Remove it and your query should be fine

    0 讨论(0)
提交回复
热议问题