本文共 2384 字,大约阅读时间需要 7 分钟。
- SELECT E.DEPTNO, COUNT(E.EMPNO)
- FROM EMP E
- WHERE E.EMPNO IS NOT NULL
- GROUP BY E.DEPTNO
- HAVING COUNT(E.EMPNO) > 0;
-
- SELECT *
- FROM EMP E
- WHERE E.SAL >
- (
- SELECT P.SAL
- FROM EMP P
- WHERE P.ENAME = 'SMITH'
- );
-
- SELECT E.ENAME , P.ENAME
- FROM EMP E, EMP P
- WHERE E.MGR = P.EMPNO(+);
-
- SELECT E.ENAME, P.ENAME
- FROM EMP E, EMP P
- WHERE E.MGR = P.EMPNO(+)
- AND E.HIREDATE < P.HIREDATE;
-
- SELECT E.ENAME, D.DNAME
- FROM EMP E, DEPT D
- WHERE E.DEPTNO(+) = D.DEPTNO;
-
- SELECT E.ENAME, D.DNAME
- FROM EMP E, DEPT D
- WHERE E.DEPTNO = D.DEPTNO
- AND E.JOB = 'CLERK';
-
- SELECT MIN(E.SAL), E.JOB
- FROM EMP E
- GROUP BY E.JOB
- HAVING MIN(E.SAL) > 1500;
-
- SELECT E.ENAME,D.DEPTNO
- FROM EMP E, DEPT D
- WHERE E.DEPTNO = D.DEPTNO
- AND E.JOB = 'SALESMAN';
-
- SELECT E.ENAME
- FROM EMP E
- WHERE E.SAL >
- (
- SELECT AVG(P.SAL)
- FROM EMP P
- );
-
- SELECT E.NAME
- FROM EMP E
- WHERE E.ENAME != 'SCOTT'
- AND E.JOB =
- (
- SELECT P.JOB
- FROM EMP P
- WHERE P.ENAME = 'SCOTT'
- );
-
- SELECT E.ENAME, E.SAL
- FROM EMP E
- WHERE E.SAL = ANY
- (
- SELECT P.SAL
- FROM EMP P
- WHERE P.DEPTNO = 30
- );
-
- SELECT E.ENAME, E.SAL
- FROM EMP E
- WHERE E.SAL > ALL
- (
- SELECT P.SAL
- FROM EMP P
- WHERE P.DEPTNO = 30
- );
-
- SELECT D.DEPTNO, D.DNAME, D.LOC, COUNT(E.EMPNO)
- FROM EMP E, DEPT D
- WHERE E.DEPTNO(+) = D.DEPTNO
- GROUP BY D.DEPTNO, D.DNAME, D.LOC;
-
- SELECT E.ENAME, D.DNAME, E.SAL
- FROM EMP E, DEPT D
- WHERE E.DEPTNO = D.DEPTNO(+);
-
- SELECT DISTINCT E.EMPNO, E.ENAME, E.JOB, E.DEPTNO
- FROM EMP E,
- (
- SELECT P.JOB, P.DEPTNO
- FROM EMP P
- GROUP BY P.JOB, P.DEPTNO
- ) M
- WHERE E.DEPTNO != M.DEPTNO
- AND E.JOB = M.JOB;
-
- SELECT COUNT(E.EMPNO), D.DEPTNO, D.DNAME, D.LOC
- FROM EMP E, DEPT D
- WHERE E.DEPTNO(+) = D.DEPTNO
- GROUP BY D.DEPTNO, D.DNAME, D.LOC;
-
- SELECT MIN(E.SAL)
- FROM EMP E
- GROUP BY E.JOB;
-
- SELECT E.DEPTNO, MIN(E.SAL)
- FROM EMP E
- WHERE E.JOB = 'MANAGER'
- GROUP BY E.DEPTNO;
-
-
- SELECT E.ENAME,
- (E.SAL + NVL(E.COMM,0))*12 SALBYYEAR
- FROM EMP E
- ORDER BY SALBYYEAR;
-
转载地址:http://ystkl.baihongyu.com/