Can someone please explain the difference between the following queries. The joins in the sub queries look the same but the first runs okay and the second does not. In the second query the sub query does not seem to have access to the alias table e.
QUERY1
select e.ename
,e.deptno
,(
select count(*)
from emp d
where e.deptno = d.deptno
) dept_cnt
from emp e
order by 2;
QUERY 2
select e.ename
,e.deptno
,(
select count(*)
from emp d
inner join e
ON d.deptno = e.deptno
) dept_cnt
from emp e
order by 2;
The second query has bad syntax:
Making an inner join with a table alias is not possible.