Last answered:

14 Jul 2022

Posted on:

12 Jul 2022


try to group by m.emp_no but shows errors

My code is following:

select m.emp_no, m.first_name, m.last_name, d.dept_no, d.from_date
from employees m
left join
dept_manager d on m.emp_no = d.emp_no
group by m.emp_no
order by dept_no desc, emp_no;

I tried to group by m.emp_no but shows error following.

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

1 answers ( 0 marked as helpful)
Posted on:

14 Jul 2022


Hi I-Cheng!
Thanks for reaching out.

Please, use the following query:
set @@global.sql_mode := replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '');
Then restart the Workbench in order to save the new settings. This should resolve this error 1055.

Hope this helps.

Submit an answer