SQL Practice Logo

SQLPractice Online

CASE Statements & Conditional Logic: Mistakes

Module: SQL Fundamentals

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