19.1.2 - Common Table Expressions (CTEs)
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What does CTE stand for?
💡 Hint: Think of temporary results in SQL.
Write a simple CTE to get total sales from an orders table by region.
💡 Hint: Remember to use the SUM function and GROUP BY.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What keyword is used to define a CTE?
💡 Hint: Think about how we start a new SQL block.
CTEs can reference themselves. Can they be used for hierarchical data?
💡 Hint: Consider what recursion allows us to do.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Write a CTE that computes the average sales for each region and returns those above a certain threshold, while using ranking to list them.
💡 Hint: Consider how averages are calculated with GROUP BY.
Create a recursive CTE that traces a product's lineage through categories and subcategories, displaying each step.
💡 Hint: Focus on constructing the category tree with proper joins.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.