select d.department_id "Department Nummber", department_name,
nvl(last_name, 'NoManager!') "Manager",
job_id
from departments d left outer join employees e on (d.manager_id=e.employee_id)
natural join jobs j
order by 1;
I can't figure out the result of the above query, which returns 11 rows when executed.. . The mystery is that the very same query returns 513 rows when "job_id" is removed from the select list or the whole list is replaced with count(*) where the returned count of rows is also 513.
I believe it's the natural join that's causing the unexplaindly varying results, as replacing
natural join jobs
with
join jobs using(job_id)
always yields 11 rows, as expected, and "solves" the issue.
I'm using SQLDeveloper and Oracle Database 11g. I'd appreciate any explanation as to how this is.
Thank you.