Snowflake can turn a three-cent invoice total into four cents by rounding each line first
Two fixed-point amounts are enough to test whether a SQL agent follows the billing policy or just formats the result.
Ask a SQL agent to “show the invoice total to two decimal places,” and there are two places it might put ROUND: inside SUM, where it changes each line, or outside SUM, where it changes only the total. Both queries can return a number with two decimal places. They need not return the same number. Snowflake’s ROUND reference documents half-away-from-zero as the default for decimal halfway values, and its SUM reference documents what gets added.
A two-line reconciliation test
Use a synthetic invoice with two unrounded line amounts of 0.015 each. The fixed-point cast makes this a test of rounding order rather than of a floating-point approximation near the halfway value. Snowflake’s ROUND reference cautions that floating-point values might not round as expected.
WITH invoice_lines AS (
SELECT column1::NUMBER(10,3) AS amount
FROM VALUES (0.015), (0.015)
)
SELECT
SUM(ROUND(amount, 2)) AS sum_of_rounded_lines,
ROUND(SUM(amount), 2) AS rounded_invoice_total
FROM invoice_lines;
The expected results under the documented rules are 0.04 and 0.03. In the first expression each 0.015 becomes 0.02, and the two rounded lines are added. In the second expression the raw values sum to 0.030, which becomes 0.03 when rounded to two places. These are calculated expectations for the fixture, not results from a live Snowflake account.
Put the rounding step in the metric definition
If the report must reconcile to the sum of separately rounded line amounts, make line-level rounding explicit. If the invoice policy says to add unrounded amounts and round once, make invoice-level rounding explicit instead. If the reporting model already stores authoritative posted totals, consider using those as the reconciliation target rather than asking the agent to reconstruct them from raw amounts. Neither SQL expression establishes what the billing system actually posted.
For an acceptance test, give the agent the same fixture under both policies and check the result and the generated SQL. Document the rounding mode separately from the rounding stage: Snowflake also supports explicit HALF_TO_EVEN for fixed-point inputs, but choosing a mode does not tell the agent where to apply it. The two-line fixture makes that missing instruction visible before anyone has to reconcile a real invoice.
sources
- Snowflake SQL reference: ROUNDdocs.snowflake.com
- Snowflake SQL reference: SUMdocs.snowflake.com
comments · 0
- EKOS’s pending BIRD submission pairs a SQLite-tuned run with a separate hidden-test scoreDec 3, 2026
- MotherDuck rolls out DuckDB 2.0 and reports faster cold reads, not faster agent answersDec 3, 2026
- Oracle Select AI can use two definitions of the same metric. Source order won’t break the tieDec 3, 2026