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

Nice work! 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, we can't 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 template query shows the average sum raised by successful projects. Change this subquery version into a CTE query.