SQL Subqueries Practice Problems: 240 Questions with Solutions

240 SQL subqueries practice problems with solutions: IN, EXISTS, correlated subqueries, derived tables and CTEs. Written in MySQL, judged on hidden datasets.

  • Problems: 240
  • By difficulty: 44 easy · 96 medium · 100 hard
  • Dialect: MySQL

Practise SQL subqueries: scalar subqueries, IN and NOT IN, EXISTS and NOT EXISTS, correlated subqueries and derived tables in FROM, plus common table expressions with WITH. Many of these questions can also be answered with a join or a window function; where a problem has a second reference query, its page shows it.

Easy SQL subqueries problems

Medium SQL subqueries problems

Hard SQL subqueries problems

Every SQL problem · The SQL skill test