Advancedcomparison
CTE vs subquery vs temporary table: when do you use each?
Quick answerFree
CTEs for readability and recursion; whether they are materialised depends on the engine. Subqueries for simple one-off logic; correlated ones may run per row.
Detailed answer· 49 words
Interview PrepUnlock the full answer with Interview Prep
Get a 49-word model answer, 4 key points and a visual explainer, plus 247 more SQL questions.
Also in Pro (₹499 / 90 days).
Key points· 4 points
Interview PrepUnlock with Interview Prep
Visual explainer· animated, step by step
Interview PrepUnlock with Interview Prep
+ 247 more SQL questions in Interview Prep, each with the full answer.