<i>and convert that in turn into a deeeeeeeply nested</i><p>I find that CTEs are the solution to deep nesting.  There are very few times that I haven&#x27;t been able to reduce the amount of nesting down to 2 levels (just the a single query with a subquery as part of an exists or something).<p>That&#x27;s obviously a problem if you don&#x27;t have access to CTEs (mysql) or CTEs are an optimization boundary (postgres), but if you&#x27;re working with a product that does not have those issues, then CTEs can really clean up a lot of sql.