ELSE is not a standalone SQL statement. It is a reserved keyword that finishes a conditional construct by defining what should happen when none of the earlier conditions are satisfied.1. In a CASE expression (ANSI SQL) - Appears once, after all WHEN clauses and before END. - If omitted, the CASE expression returns NULL when no WHEN matches. - Data type of the ELSE result must be compatible with the THEN results.2. In procedural control-flow blocks (dialect specific) - Used with IF … ELSE … END IF (MySQL, PL/pgSQL, T-SQL) or BEGIN … END blocks. - Marks the alternate set of statements executed when the IF condition is false.Caveats- Only one ELSE clause is allowed per CASE or IF.- In SELECT lists, keep ELSE expressions side-effect free.- In some engines, ELSE cannot contain another control-flow statement inside a CASE expression but can inside procedural IF blocks.
CASE, WHEN, END, IF, COALESCE, NULLIF, DECODE (Oracle)
SQL-92 (optional feature F511)
The expression returns NULL when no WHEN condition matches, which may propagate NULLs in your result set.
All THEN and ELSE expressions must be implicitly convertible to a common data type in the target database; otherwise, a type mismatch error occurs.
Yes. Whether you use simple or searched CASE syntax, ELSE behaves the same and supplies the default value.
Yes. CASE can be nested within THEN or ELSE to model complex logic, but readability can suffer. Prefer breaking logic into separate computed columns or CTEs.