Alternative code using group by
This code works as well and it is much simpler. Are there any cons I am not aware?
emp_manager e2 ON e1.emp_no = e2.manager_no
GROUP BY e1.emp_no;
Bravo! This is also a correct solution!
Hope this helps.
I have tried using group by but i got the error code below. do you have any idea why?
FROM emp_manager em1
JOIN emp_manager em2 ON em1.emp_no = em2.manager_id
GROUP BY em1.emp_no;
Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employees.em1.dept_no' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by