Skip to main content
SQL • LESSON 109

Basic CASE

How can we classify employees based on salary?

Advanced3 Minutes1220 XP
🤔 THE QUESTION

How can we classify employees based on salary?

💡 WHAT IS IT?

CASE evaluates sequential WHEN ... THEN conditions to return custom categorical labels.

🎯 WHAT IS IT USED FOR?

Salary banding, customer tiering (Bronze/Silver/Gold), score categorization.

💻 EXAMPLE
SELECT
name,
salary,
CASE
    WHEN salary >= 100000 THEN 'High'
    WHEN salary >= 70000 THEN 'Medium'
    ELSE 'Low'
END AS salary_band
FROM employees;

🎯 Mission Objectives

Practice typing production-grade SQL code for Basic CASE.

  • CASE expression
  • WHEN ... THEN ... ELSE
  • Salary banding
  • Column projection