Use CASE to choose a value from conditions in a query. This chapter builds from searched and simple forms to NULL-aware classification, calculations, and conditional aggregation. The examples target MySQL and PostgreSQL unless a dialect is explicitly named.
CASE Expressions
Conditional values, NULLs, and conditional aggregation