SQL – Subqueries and CTEs
Practice SQL subqueries and Common Table Expressions (CTEs) commonly asked in interviews. Cover correlated subqueries, nested queries, and readable CTE patterns. Write queries and receive feedback on correctness and approach. Ideal for intermediate SQL interview prep. First 2 questions are free with full feedback.
- Level Intermediate
- Questions 12
Try any track free — first 2 questions include full AI feedback. Subscribe to finish the track and unlock everything. Type or speak your answer — the first 2 questions include scoring and detailed AI feedback.
Sample sql – subqueries and ctes interview questions
Preview 6 questions from this track in quiz order. In the full quiz you answer one at a time — type or speak — then get a score and feedback.
-
What is a subquery and when would you use one?
What a strong answer includes
Query inside another query for filtering or calculation.
-
Write a query to find employees who earn more than the average salary.
What a strong answer includes
Uses a subquery in the WHERE clause.
-
What is a CTE and why use it instead of a subquery?
What a strong answer includes
Improves readability and can be reused.
-
Write a query using a CTE to calculate total sales by region, then filter regions above a threshold.
What a strong answer includes
Clear WITH clause and final SELECT.
-
Explain a correlated subquery.
What a strong answer includes
References the outer query and runs per row.
-
Write a query to find customers who have placed more orders than the average customer.
What a strong answer includes
Uses a subquery or CTE for the average.