1432
MySQLERRORNotableStored RoutinesHIGH confidence

AGGREGATE is not supported for stored functions

Production Risk

Low — compile-time error; the routine will not be created.

What this means

ER_SP_NO_AGGREGATE (1432, SQLSTATE 42000) is raised when a stored function attempts to use AGGREGATE, which is not supported in that context.

Why it happens
  1. 1Using AGGREGATE keyword inside a stored function body
  2. 2Attempting to create a user-defined aggregate function via CREATE FUNCTION syntax instead of the UDF interface
How to reproduce
trigger — this will error
trigger — this will error
-- Attempting to create aggregate stored function:
CREATE FUNCTION my_agg() RETURNS INT
  AGGREGATE RETURNS INT
BEGIN
  RETURN 1;
END;

expected output

ERROR 1432 (42000): AGGREGATE is not supported for stored functions

Fix

Use GROUP BY with regular aggregate functions instead

Use GROUP BY with regular aggregate functions instead
-- Use standard aggregate functions in queries, not in stored functions
SELECT SUM(amount) FROM orders GROUP BY customer_id;

Why this works

Standard SQL aggregate functions work in queries; AGGREGATE keyword is not valid for stored functions.

Sources
Official documentation ↗

MySQL 8.0 — 1432 ER_SP_NO_AGGREGATE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors