Reputation: 39
I need help on transforming query, How can I rewrite this query with join into a query with subquery. Both the original and transformed query should return same results. I just need to see their differences in terms of autotrace and explain plan. Thank You.
select emp.employee_id, count(jh.department_id) as ID_Count
from employees emp left outer join
job_history jh
on emp.employee_id = jh.employee_id
group by emp.employee_id;
Upvotes: 0
Views: 36
Reputation: 2024
You can use this code:
select emp.employee_id,
(select count(jh.department_id)
from job_history jh
where emp.employee_id = jh.employee_id
) as ID_Count
from employees emp;
I hope I helped!
Upvotes: 2