Skip to content
Advertisement

How to find a destinct values in a table that are larger than all values that reference it?

I need to find the names of bosses who were hired after all the hired date of all their subordinates. Here is what I have got so far:

The idea was to check that the boss.hire_date is larger than the earliest and latest hire_date of his subordinates.

However I get following error message:

ORA-00934: group function is not allowed here

Any idea how I have to restructure the query?

Advertisement

Answer

This should work better

Note that I have supposed that a boss can’t manage itself. In an usual hierarchical database, the top manager has its manager_id field = NULL. If in your data a boss can have its manager_id =i ts own employee_id, it wont work.

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