In standard SQL, if you have a GROUP BY clause, all columns that are not part of this should be in aggregates. In MySQL, this rule has been softened by design.
For example, this is allowed in MySQL, but not in standard SQL:
SELECT customer_id, country, SUM(amount) FROM records GROUP BY customer_id
There is one caveat: MySQL assumes that you know what you are doing. If the same client has entries in several countries, the request will simply capture the first country in the table, not paying attention to all the others. In addition, since the order of the strings is undefined, and there is no ORDER BY, you can get different results each time the query is run.
In standard SQL, you have two options:
SELECT customer_id, country, SUM(amount) FROM records GROUP BY customer_id, country
or
SELECT customer_id, MIN(country), SUM(amount) FROM records GROUP BY customer_id
source share