Last answered:

03 Nov 2023

Posted on:

03 Nov 2023

0

I keep getting an error message after trying to run query

Tried running a query using what was given in the video but keep getting an error 


select emp_no, from_date, to_date, count(emp_no) as NUM
from dept_emp
group by emp_no
having NUM > 1;


above is the code 


Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employees.dept_emp.from_date' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

here is the error I keep getting 

1 answers ( 0 marked as helpful)
Instructor
Posted on:

03 Nov 2023

0

Hi Jesulayomi!
Thanks for reaching out.


Please, run the following code:

set @@global.sql_mode := replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '');

Then, restart the Workbench in order to save the new settings.


Hope this helps.
Best,
Tsvetelin

Submit an answer