https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
SQL-92 and earlier does not permit queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are not named in the GROUP BY clause. For example, this query is illegal in standard SQL-92 because the nonaggregated name column in the select list does not appear in the GROUP BY:
SQL-92和更早版本不允许select列表、HAVING条件或ORDER BY列表引用GROUP BY子句中未命名的非聚合列的查询。例如,这个查询在标准SQL-92中是非法的,因为select列表中的非聚合名列不会出现在GROUP BY
SELECT o.custid, c.name, MAX(o.payment)
FROM orders AS o, customers AS c
WHERE o.custid = c.custid
GROUP BY o.custid;
要使查询在SQL-92中合法,必须从select列表中删除name列,或者在GROUP BY子句中删除named列。