Chapter 20

CASE Expression Family

Abstract

SQL is declarative, so we do not have the concept of flow control in procedural languages. Instead, we use expressions that come from primitive recursive function theory to select a result from among possible values.

Keywords

CASE expression

CASE expressions with GROUP BY

CHECK() clauses

COALESCE()

ELSE

Material implication

NULLIF()

Smisteru transform

THEN

WHEN

SQL-92 added new expressions and extended the rules for old ones to make the language more orthogonal. Basically, anything that looks reasonable is probably legal syntax. But SQL is declarative, so we do not have the concept of flow control in procedural languages. Instead, we use expressions that come from primitive recursive function theory ...

Get Joe Celko's SQL for Smarties, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.