Skip to main content
SQL • LESSON 115

CASE with NULL

How can we classify employees who have no manager?

Advanced3 Minutes1280 XP
🤔 THE QUESTION

How can we classify employees who have no manager?

💡 WHAT IS IT?

WHEN column IS NULL inside CASE handles missing or unassigned foreign keys with descriptive labels.

🎯 WHAT IS IT USED FOR?

Executive hierarchy classification, identifying unassigned work orders, null handling.

💻 EXAMPLE
SELECT
name,
CASE
    WHEN manager_id IS NULL THEN 'Top Level'
    ELSE 'Has Manager'
END AS hierarchy_level
FROM employees;

🎯 Mission Objectives

Practice typing production-grade SQL code for CASE with NULL.

  • CASE with IS NULL
  • Hierarchy level tags
  • Missing foreign key handling
  • Organizational logic