SQL Fundamentals

CASE Statements & Conditional Logic: Mistakes

CASE WHEN status = 'active' THEN 'Active' WHEN status = 'pending' THEN 'Pending' END CASE WHEN status = 'active' THEN 'Active' WHEN status = 'pending' THEN 'Pen

CASE WHEN status = 'active' THEN 'Active' WHEN status = 'pending' THEN 'Pending' END

CASE WHEN status = 'active' THEN 'Active' WHEN status = 'pending' THEN 'Pending' ELSE 'Unknown' END

Missing ELSE clause returns NULL for unmatched rows. Always include ELSE with default value to prevent unexpected NULLs in results.

Medium