Expected HAVING facts are assertions only.

highlighted = computed this step

Honest by construction

Expected HAVING facts are assertions only.

compiler is source of truth\text{compiler is source of truth}

Render checked groups

The guarded HAVING filter renders 2 output groups after recomputation.

checked groups=2\text{checked groups}=2

HAVING examples are tiny finite group-filter transforms; SQL dialect completeness, optimizer behavior, indexing, and product claims are out of scope.

Honest by construction: base rowsidregionstatusqty1eastopen22eastopen33westopen14westclosed45northNULL26northopen1 WHERE before groupingsourceinputwhereTruthgroupedRole0[1, east, open, 2]TRUEgrouped1[2, east, open, 3]TRUEgrouped2[3, west, open, 1]TRUEgrouped3[4, west, closed, 4]TRUEgrouped4[5, north, NULL, 2]TRUEgrouped5[6, north, open, 1]TRUEgrouped GROUP BY bucketskeysourceRowsrowCount[east][0, 1]2[west][2, 3]2[north][4, 5]2 Aggregate facts per groupkeysourceRowsaggregates[east][0, 1]{n:2, total_qty:5}[west][2, 3]{n:2, total_qty:5}[north][4, 5]{n:2, total_qty:3} HAVING result per groupkeypredicatetruthoutputRole[east]total_qty ge 5TRUEkept[west]total_qty ge 5TRUEkept[north]total_qty ge 5FALSEdropped HAVING output groupsregionntotal_qtyeast25west25 HAVING factsfactvalueinputRowCount6whereKeptRows6whereDroppedRows0groupCount3aggregateCount2outputGroupCount2havingTrueCount2havingFalseCount1havingUnknownCount0groupOrderfirst_seen_after_wherepipelineWHERE_before_GROUP_BY_then_HAVING

Try to tamper

Wrong expected facts, derived sidecars, missing group columns, bad aggregates, bad HAVING aliases, bools, and floats fail closed.

tamper rejected\text{tamper rejected}

Summary

The book shows exact finite WHERE, GROUP BY, COUNT, SUM, and HAVING behavior only.

scoped HAVING model\text{scoped HAVING model}