Skip to main content
SQL โ€ข LESSON 115

CASE with NULL

How can we classify employees who have no manager?

Advancedโฑ 3 Minutesโญ 1280 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