4102
MariaDBWARNINGCriticalMEDIUM confidence
Aggregate functions with ROLLUP behave differently and are deprecated in this context
Production Risk
Low — Queries continue to execute but may produce different results in future MySQL versions.
Why it happens
- 1A query uses non-standard aggregate expressions together with GROUP BY WITH ROLLUP.
Fix
Use GROUPING() to distinguish ROLLUP super-aggregate rows
Use GROUPING() to distinguish ROLLUP super-aggregate rows
SELECT col, GROUPING(col), SUM(val) FROM t GROUP BY col WITH ROLLUP;
Why this works
GROUPING() returns 1 for super-aggregate rows, making the intent explicit and standards-compliant.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 4102 ER_WARN_DEPRECATED_AGGREGATE_WITH_ROLLUP
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev