MySQL & MariaDB error 3028 ER_AGGREGATE_ORDER_FOR_UNION
MySQLExpression #… of ORDER BY contains aggregate function and applies to a UNION, EXCEPT or INTERSECT
MariaDBExpression #… of ORDER BY contains aggregate function and applies to a UNION
How the message changed between versions