Real queries constantly need conditional logic: label a score as a fifty or a duck, substitute a default when a value is missing, or avoid dividing by zero. SQL provides this through CASE expressions and the NULL-handling functions COALESCE and NULLIF. Together they let you transform and clean data inline, embedding decision logic directly into a query without resorting to application code.
CASE is SQL's if-then-else, evaluating conditions and returning a value for the first that matches. COALESCE returns the first non-NULL value from a list, perfect for defaults, and NULLIF returns NULL when two values are equal, most famously to turn a zero denominator into NULL and dodge division errors. These small tools solve an enormous share of everyday data-shaping problems.
Mastering conditional and NULL-handling expressions is what makes your queries robust against the messy reality of data. Missing values, edge cases, and category logic are everywhere, and handling them cleanly inside SQL keeps logic close to the data, consistent across consumers, and free of the scattered, error-prone conditionals that otherwise pile up in every application that touches the same table.