4 ms·
Have some links on using CTEs to replace nested queries and how it helps ? I've used SQL enough to have to write nested queries, haven't dove further than that
by moonchrome 5y ago
Have some links on using CTEs to replace nested queries and how it helps ?
I've used SQL enough to have to write nested queries, haven't dove further than that.
- ducharmdev 5y agoHere's an article with some examples: https://learnsql.com/blog/sql-subquery-cte-difference/ https://learnsql.com/blog/sql-subquery-cte-difference/ You can think of CTEs as a way to save an intermediate query as a sort of temp variable/table that can be used in the final statement following `WITH something AS (...)`. They are great for flattening your queries and giving descriptive names to subqueries, and you can chain multiple WITHs together as well.