Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Basic CTE
12. CTE vs. subquery
Summary

Instruction

Alright. The last thing we'll discuss in this part is the difference between subqueries and CTEs. In fact, all of the examples and exercises from this part could be rewritten with subqueries. For now, CTEs simply increase readability of your query. A query with a subquery will look similar to that with a CTE, but the CTE version makes your query look more structured and easier to read.

However, it is not possible to create correlated subqueries with CTEs. Don't worry, though – you will soon find out that there are also certain things that CTEs can and subqueries can't do.

Exercise

The query shows the average sum raised by those projects which succeeded. Change the version with a subquery into a version with a CTE.