SELECT MIN (SAL) MINIMUM
FROM EMP;
Без ошибок
SELECT MAX(SAL), MIN (SAL), AVG (SAL)
FROM EMP;
Без ошибок
SELECT JOB,
MAX (SAL) MAXIMUM,
MIN (SAL) MINIMUM
FROM EMP
GROUP BY JOB;
Без ошибок
SELECT COUNT (*) MANAGERS
FROM EMP
WHERE JOB = 'MANAGER';
Без ошибок
SELECT JOB,
AVG (SAL) AVSAL,
AVG(SAL*12+NVL(COMM,0)) AVCOMP
FROM EMP
GROUP BY JOB;
Server: Msg 195, Level 15, State 10, Line 112
'NVL' is not a recognized function name.
SELECT МАХ (SAL) - MIN (SAL) DIFFERENCE
FROM EMP;
Server: Msg 195, Level 15, State 10, Line 110
'МАХ' is not a recognized function name.
SELECT DEPTNO, COUNT (*)
FROM EMP
GROUP BY DEPTNO
HAVING COUNT (*) > 3;
Без ошибок
Дополнительные задания:
SELECT EMPNO
FROM EMP
GROUP BY EMPNO
HAVING COUNT (*) > 1;
Без ошибок
SELECT MGR, MIN (SAL)
FROM EMP
GROUP BY MGR
HAVING MIN (SAL) >= 1000
ORDER BY MIN (SAL) ;
Без ошибок
Решения упражнений: урок 7
SELECT Е . ENAME, D . DNAME
FROM ЕМР Е, DEPT D
WHERE E.DEPTNO = D.DEPTNO
ORDER BY D. DNAME;
Без ошибок
SELECT E.ENAME, E.DEPTNO, D.DNAME
FROM EMP E, DEPT D
WHERE E.DEPTNO = D.DEPTNO;
Без ошибок
SELECT E.ENAME, D.LOC LOCATION, D.DNAME
FROM EMP E, DEPT D
WHERE E.DEPTNO = D.DEPTNO
AND E.SAL > 1500;
Без ошибок
SELECT E.ENAME, E.JOB, E.SAL, S. GRADE
FROM EMP E,SALGRADE S
WHERE E.SAL BETWEEN S.LOSALAND S.HISAL;
Server: Msg 170, Level 15, State 1, Line 112
Line 112: Incorrect syntax near 'S'.
SELECT E.ENAME, E.JOB, E.SAL, S. GRADE
FROM EMP E, SALGRADE S
WHERE E.SAL BETWEEN S.LOSAL AND S.HISAL
AND S .GRADE = 3;
Без ошибок
SELECT E.ENAME, E.SAL, D.LOC LOCATION
FROM EMP E, DEPT D
WHERE E.DEPTNO = D.DEPTNO
AND D . LOC = ' DALLAS ' ;
Без ошибок
SELECT D.DEPTNO, D.DNAME
FROM EMP E, DEPT D
WHERE E.DEPTNO(+) = D.DEPTNO
AND E.EMPNO IS NULL;
Server: Msg 170, Level 15, State 1, Line 112
Line 112: Incorrect syntax near ')'.
SELECT EMPS.EMPNO,
EMPS.ENAME,
MGRS.EMPNO MGRNO,
MGRS.ENAME MGR_NAME
FROM EMP EMPS, EMP MGRS
WHERE EMPS.MGR = MGRS.EMPNO;
Без ошибок
SELECT EMPS.EMPNO,
EMPS.ENAME,
MGRS.EMPNO MGRNO,
MGRS. ENAME MGR_NAME
FROM EMP EMPS, EMP MGRS
WHERE EMPS.MGR = MGRS. EMPNO(+);
Server: Msg 170, Level 15, State 1, Line 115
Line 115: Incorrect syntax near ')'.
SELECT JOB
FROM EMP
WHERE HIREDATE BETWEEN '01-JAN-83'
AND '30-JUN-83'
INTERSECT
SELECT JOB
FROM EMP
WHERE HIREDATE BETWEEN '01-JAN-34'
AND '30-JUN-84'
Server: Msg 156, Level 15, State 1, Line 114
Incorrect syntax near the keyword 'INTERSECT'.
Дополнительные упражнения
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.