Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Sub Query : Improper Result !

$
0
0
Hello,

I'm executing following query:

List the empno, ename, and dept name for any employees that work in the same department as CLARK.
Use a subquery in the where clause to determine which department CLARK works in.

Here is my query:

Code:

SELECT e.empno, e.ename, d.dname
FROM EMP e , DEPT d
WHERE d.DEPTNO IN (SELECT DEPTNO
                FROM EMP
                WHERE EMPNO = 7782)
AND d.DEPTNO = e.DEPTNO;


But the problem with above query is that it is listing CLARK details as well. How can I omit CLARK details as I just want to display others who work with CLARK ?

Thanks

Viewing all articles
Browse latest Browse all 13329

Trending Articles