Row Functions
Row Functions
Per-row computation — strings, numbers, dates and times, NULL handling, and the CASE expression. The "make each row a little smarter" half of SQL, where most data-quality fixes live.
Suggest an editRow Functions
Aggregate functions (previous module) summarise many rows into one. Row functions are the opposite — they take one row and produce one value, on a per-row basis. They're the per-row computation layer: lowercase a name, parse a date, substitute a default for a NULL, branch on a value with CASE. Most data-quality fixes — "this column has trailing whitespace," "these dates are in the wrong timezone," "NULL means default" — happen here.
Place in the curriculum
- Prerequisites: Foundations. The
SELECTprojection andWHEREfiltering chapters introduce row functions in passing; this module covers the catalogue properly. - Followed by: Window Functions. Window functions blend per-row and per-group computation — they keep the original row and also compute aggregates over a window. The row-function fluency you build here makes window functions much easier.
Chapters
- Strings —
LOWER,UPPER,TRIM,LENGTH,SUBSTRING,REPLACE,CONCAT,LIKE/SIMILAR TO/regex. - Numbers — arithmetic,
ROUND,FLOOR,CEIL,MOD,ABS, type coercion and integer-division traps. - Dates and Times —
DATE_TRUNC,EXTRACT,INTERVALarithmetic, timezones, parsing and formatting. - NULL and Three-Valued Logic —
COALESCE,NULLIF,IS DISTINCT FROM, the truth tables that explain every NULL bug, and the patterns to make NULL-handling explicit. - CASE Expressions —
CASE WHEN ... THEN ... ELSE ... END. The if-else chain in SQL; powers bucket categorisation, conditional aggregation, and pivot patterns.
Mark as read