Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using a subquery to display names and max salaries by department: HR Schema

Daniel TaitMar 14 2013 — edited Mar 14 2013
Using the HR schema, I'm trying to write a query which will display the names and salaries of those employees who earn the highest salaries in their respective departments.

I wrote the query:

SELECT first_name, last_name, salary
FROM employees
WHERE salary =
(SELECT department_id, MAX(salary) FROM employees GROUP BY department_id);


However, this query does not execute correctly but I'm not sure why?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2013
Added on Mar 14 2013
7 comments
3,154 views