Q:

SQL select records common to a column

I have an emp table like this
EMPNO | JOB | DEPTNO
_____________________

  1   |  A  |   10

  2   |  B  |   20

  3   |  C  |   10

  4   |  A  |   20

I want to write a query to List the jobs common to department 10 and 20. 
So the output as per the data provided should be
A

which is common to both deptno 10 and 20
I am trying this but it doesn't give me any output.
select job, deptNo from emp group by job having deptno = 20 and deptno = 10; /*6*/

A:

Try this
    select  job
from    emp e1
where   e1.deptno = 10
and     exists ( select 1
         from   emp e2
         where  e2.deptno = 20
         and    e1.job    = e2.job
    )
group by job;

