Reputation: 540
I am trying to create a query that will display the name, dep no. , and all the workers that work in the same dep as a specific person. I have written some code for it but its giving an error.
SELECT d.deptno ,d.ename , e.ename
FROM emp e, emp d
WHERE deptno = ( SELECT DISTINCT deptno
from emp
WHERE d.deptno = e.deptno );
Cheers
-Jay
Upvotes: 2
Views: 438
Reputation:
Try:
SELECT d.deptno AS DEPARTMENT,d.ename AS EMPLOYEE , e.ename AS COLLEAGUE
FROM emp e, emp d
WHERE d.deptno = e.deptno AND d.ename <> e.ename;
Upvotes: 2