SQL LEARNING PLATFORM
If-else logic that lives inside your SQL.
Learning Blocks
Interactive Queries
Concepts you'll master
CASE WHEN ... THEN ... END syntax
Using CASE to label and categorise rows
CASE inside aggregate functions — the pivot pattern
SELECT name, salary,
CASE
WHEN salary < 60000 THEN 'Junior'
WHEN salary < 75000 THEN 'Mid-Level'
ELSE 'Senior'
END AS band
FROM employees ORDER BY salary;SELECT
SUM(CASE WHEN salary < 60000 THEN 1 ELSE 0 END) AS junior,
SUM(CASE WHEN salary BETWEEN 60000 AND 74999 THEN 1 ELSE 0 END)
AS mid,
SUM(CASE WHEN salary >= 75000 THEN 1 ELSE 0 END) AS senior
FROM employees;✅ Interview Tip: This SUM(CASE WHEN ... END) pattern is the standard way to pivot rows into columns in SQL. It appears in almost every data analyst/data engineer interview. Know it cold.
Practice your SQL skills