Skip to content
Advertisement

SQL displaying staff with more salary than their managers

I’m trying to display staff from the same department who earn more than their managers.

This doesn’t seem to work, and I’m reallly not sure why.

Here’s a peep at how the tables are formatted:

Advertisement

Answer

The problem is that you need to correlate the subquery to match the same departement:

This answer assumes that each department would have only one manager. If there could be more than one manager, then it would be safer to write the above using exists logic:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement