SQLCASEtutorial

What is CASE WHEN in SQL? Conditional logic for beginners

CASE WHEN is "if/else inside SQL". Plain words: how to put conditions right into SELECT, the difference between searched CASE and simple CASE, bucketing numbers into categories, pivoting with one formula, and conditional aggregates. With tables and common pitfalls.

1 min readSQL · CASE · tutorial

CASE WHEN is "if/else inside a SQL query". The way to put a condition right in SELECT, UPDATE, or WHERE and get one of several values depending on the row.

This article is currently in Russian. The full English translation is on the way.

Practice on real tasks

Solve tasks in the SQL trainer with instant grading and hints.

Open trainer