Before SQL-92, programmers complained that SQL’s lack of conditional constructs forced them to rely on the host language to take certain actions based on a condition’s truth value (true, false, or unknown). To attenuate this criticism, SQL-92 introduced the CASE expression and its shorthand equivalents, COALESCE() and NULLIF(). I’ll cover CASE in this section and the other constructs in the remainder of this chapter.
The CASE expression’s important characteristics are:
If you’ve programmed before, you’ll recognize that CASE provides SQL the equivalent of the if-then-else, case, or switch statements used in procedural languages, except that CASE is an expression, not a statement.
CASE is used to evaluate ...