I have a table called employees that contains the columns.
ID | Name | Salary | Department_id | Boss_id
So all employees are listed in this no matter where they're bosses or not. If someone is not a boss then their value for Boss_id will be NULL.
The aim is, to figure out if any employees earn more than their respective bosses and by respective I mean, from the same department.
I've been working on this trying to figure it out and I'm not sure if I need a loop to loop through all the departments or if there is an easier way.