8. CASE WHEN: If-Then Logic in SQL
8.1 Why CASE WHEN Beats Manual Labels in Excel
Why. Manual Excel labels break when new rows arrive.
What. CASE WHEN builds labels with rules inside SQL — same logic every refresh.
How. Think IF in Excel → CASE WHEN in SQL.
Steps
- Write the rule in words.
- Map to WHEN … THEN ….
- Keep ELSE for the rest.
Ravindra Bagale's Tip
Link: later ch29 maps CASE to IF/IFS for Excel users.
Ravindra Bagale's Tip – मराठी
पुढे ch29 CASE ला Excel IF/IFS शी जोडतो.
Ravindra Bagale's Tip – हिंदी
आगे ch29 CASE को Excel IF/IFS से जोड़ता है।