r/DatabaseHelp • • Oct 16 '17
Oracle hr schema, subquery problem
Hi, I have been tasked with performing the following query: display the last_name, first_name, and department_id of all employees in the department that has the lowest average salary. Here is what I think the query should be: select department_id, last_name, first_name from employees where department_id in(select min(avg(salary)) from employees group by department_id); Please point me in the direction (Oracle documentation or elsewhere) to help me solve this problem. Thank you!
1
Upvotes
View all comments
Show parent comment
1
u/ScariestofChewwies Oct 17 '17
So the select in the inner query has 2 columns in it and the equals, as part of the outer query, is only expecting one. So if you remove the avg salary and only select the department_id, that should get you further. That being said, it is kind of hard to tell with them separated out like that. Can you paste the whole query as you are running it?