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

Instruction

All right! The last thing we'll discuss in this part is the difference between subqueries and CTEs. In fact, all of the examples and exercises in this part could be rewritten with subqueries.

For now, CTEs simply increase the readability of your query. A query with a subquery will look similar to a query 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 do that subqueries can't.

Exercise

The temolate query shows the average sum raised by successful projects. Change the version with a subquery into a version with a CTE.