query seems incorrect
select * from salaries group by emp_no; - I don't think this is a correct syntax. Don't we need an aggregate function to use with GROUP BY statement? Otherwise how will SQL know which salary to put for each emp_no?
Hi Eugenia!
Thanks for reaching out.
Actually, the query is correct. It returns the first salary for every employee because Workbench does not know what to return. This is very typical approach - it is returned the first matched value for the column we use in the GROUP BY clause.
Hope this helps.
Best,
Tsvetelin
In my workbench when I execute the query I get an error message:
Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employees.salaries.salary' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Hi Eugenia!
Thanks for reaching out.
To make sure you can take some of the remaining lectures of the course without unnecessary interruption, we strongly advise you to execute the following query now.
set @@global.sql_mode := replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '');
You have to restart the Workbench afterwards in order to save the new settings.
Hope this helps.
Best,
Tsvetelin