SQL Subqueries & CTE | Correlated, Recursive CTE + Interview Questions
Sumit Mittal
0:00 / 0:00
SQL Subqueries & CTE | Correlated, Recursive CTE + Interview Questions
4 865 просмотров · 2 дн. назад
Sumit Mittal
167 тыс. подписчиков
4 865 просмотров · 2 дн. назад
This is where SQL starts to feel advanced, and also where it gets really interesting.
In this video we’ll learn how to write a query inside another query, and then how to make those long, complicated queries clean and readable using CTEs. I’ll also solve the same problem in 4 different ways, so you can see there’s never just one right answer in SQL.
Here’s what we cover:
✅ Subqueries in WHERE, FROM, SELECT and HAVING
✅ Scalar, multi-row and correlated subqueries
✅ EXISTS and NOT EXISTS
✅ One problem, 4 solutions: NOT IN, LEFT JOIN, EXCEPT and NOT EXISTS
✅ CTEs using the WITH clause, and chaining multiple CTEs
✅ Recursive CTEs: employee hierarchy, management chain and Fibonacci
Then we solve 5 interview questions: Immediate Food Delivery II, Monthly Transactions II, Restaurant Growth, Game Play Analysis (day-1 retention) and a FIFA World Cup case study. Some of these are marked hard on LeetCode, but don’t worry, I break each one down step by step.
If correlated subqueries feel confusing the first time, that’s completely normal. Watch that part twice and it will click.
⏱️ Chapters
0:00 SQL Subqueries: Single Row, Multi Row, Correlated & Nested
1:58:59 CTE: WITH Clause & Recursive CTE
3:18:34 Interview Q: Percentage of Immediate Orders
3:30:13 Interview Q: Monthly Transactions & Chargebacks
3:47:31 Interview Q: Restaurant Growth
4:08:35 Interview Q: Day-1 Retention (Game Play Analysis)
4:32:56 Case Study: FIFA World Cup Match Analysis
If you want to become a Data Engineer, check out my Ultimate Data Engineering Program here: https://trendytech.in
If you want to become an AI Engineer, check out my Agentic AI Engineering Program here: https://trendytech.in/agentic-ai/
🔗 Let’s connect!
LinkedIn: / bigdatabysumit
Twitter: / bigdatasumit
Instagram: / data.engineering.by.sumit