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
Just like in your plain SQL version of your query, your cteCounts should not have a with(cteOne) clause:
cteCounts
with(cteOne)
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