SQL Conditional Logic Practice Problems: 265 Questions with Solutions

265 SQL conditional logic practice problems with solutions: CASE WHEN, IF, COALESCE and conditional aggregation. Written in MySQL, judged on hidden datasets.

  • Problems: 265
  • By difficulty: 76 easy · 127 medium · 62 hard
  • Dialect: MySQL

Practise conditional logic in SQL: CASE WHEN, IF, COALESCE and IFNULL, and conditional aggregation such as SUM(CASE WHEN … THEN 1 ELSE 0 END) to pivot rows into columns. These problems label rows into buckets, count several conditions in one pass and replace missing values — the pattern behind most "report" questions in a SQL interview.

Easy SQL conditional logic problems

Medium SQL conditional logic problems

Hard SQL conditional logic problems

Every SQL problem · The SQL skill test