SQL is a bad language for writing complex queries. Sometimes need to read inside out or bottom up, etc to make sense of it. Wish duckdb had a more procedural api.
CTE solves this problem. I prefer SQL expressions because they're composable. If you want to do things procedurally, you can just bind a result to a dataframe with duckdb.
SQL could be friendlier for complex queries. We have recently made a talk on the improvements to SQL to simplify complex expressions: https://www.youtube.com/watch?v=zhrOYQpgvkk