Help with SQL

There a two problems:

You do not have the guarantee that the result is the correct one. If you do not include all non-aggregated columns in the GROUP-BY-clause, the database engine will choose a value for each non-aggregated column in each returned row. There is a good explanation here: [mysql - What are the benefits of only_full_group_by mode? - Stack Overflow](https://What are the benefits of only_full_group_by mode?)

As mentioned above, you might get into trouble when moving to another server or database system which enforces it (it is in the SQL-92 standard !).