This is incompatible with sql_mode=only_full_group_by
SQL can work using many modes that affect the queries' syntax and validation checks. Based on the configuration of the variable sql_mode, a query can be valid and executes or can have a validation error and cannot be executed. The old versions of SQL accustomed its users to write queries that were not semantically correct. The old versions were designed to work in a "forgiving mode." Users had the chance to write any queries regardless of SQL standard compliances or semantic rules. The bad habit was corrected by introducing the sql_mode to instruct the server to work in a restrictive way to validate the query.
When running a query having “GROUP BY” against a database in MySQL, you encountered the error “this is incompatible with sql_mode=only_full_group_by." Here is the way to fix the issue. First, open “my.cnf" and replace "vim" with a name of your choice. You can find the config file at "etc/mysql” directory in a standard installation.
sudo vim /etc/mysql/my.cnf
Secondly, add the lines below to the end of its content:
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Now save the file and exit. Restart the SQL server by running
sudo service mysql restart
If you are a Windows user, "my.cnf" will be "my.ini" in the directory C:/xampp/mysql/bin/." After adding the lines above, restart the MySQL server.
I hope it helps.