Of course, you can first write the query with CTEs, then convert to the nested form. It's just substitution.
(For bonus points, keep the original CTE form, but commented out, to help with troubleshooting further down the road.)
(For bonus points, keep the original CTE form, but commented out, to help with troubleshooting further down the road.)
Sadly, in most cases, this mean you have to decide between ugly and performant, or nice and slow code.
I hope this gets fixed soon. Nobody should have to write queries like this:
CTEs allow you to build "lisp-like" pipeline where you transform your data as you go and are able to give the intermediate results useful names.