Documentos de Académico
Documentos de Profesional
Documentos de Cultura
DNAME
From dept d
where
not exists (SELECT * FROM EMP E WHERE D.DEPTNO = E.DEPTNO);
2)SELECT b.ENAME
FROM EMP a,EMP b
WHERE a.EMPNO=b.MGR
AND a.SAL<b.SAL;
5)
6) select *
from emp
where DEPTNO=( select deptno from dept where DNAME='ACCOUNTING');
7) select e.ename,e.sal,d.deptno,d.dname
from emp e, dept d
where e.deptno(+) =d.deptno;
8) select e.ename,e.sal,d.deptno,d.dname
from emp e, dept d
where e.deptno =d.deptno(+);
9)
SELECT DISTINCT d.dname
FROM dept d, emp e
WHERE d.deptno=e.deptno
AND 3 >ANY (select count(deptno) FROM emp group by deptno );
11)
select e1.ENAME, e1.SAL
from EMP e1, emp e2
where e1.HIREDATE=e2.HIREDATE;
SELF-JOINS
1) select * from
emp
where emp.sal = (select sal from emp where ENAME='SMITH');
2)
CORRELATED SUBQUERIES
1) select MAX(Sal) as "2nd Max" from Emp
WHERE Sal <> (select MAX(Sal) from Emp);
2)
select min(Sal) as "2nd Min" from Emp
WHERE Sal <> (select Min(Sal) from Emp);
3) select e.ename
from emp e
where e.sal> ( select avg(sal) from emp e2 where e.deptno=e2.deptno);