--7강
--1번
SELECT DEPTNO , TRUNC(AVG(SAL)) AS AVG_SAL , MAX(SAL) , MIN(SAL) , COUNT(*) AS CNT
FROM EMP
GROUP BY DEPTNO ;
--2번
SELECT JOB , COUNT(*) FROM EMP
GROUP BY JOB HAVING COUNT(*) >= 3;
--3번
SELECT TO_CHAR(HIREDATE,'YYYY') AS HIRE_YEAR , DEPTNO , COUNT(*) AS CNT
FROM EMP
GROUP BY TO_CHAR(HIREDATE,'YYYY') , DEPTNO;
--4번
SELECT NVL2(COMM, 'O' , 'X' ) , COUNT(*) AS CNT
FROM EMP
GROUP BY NVL2(COMM, 'O' , 'X' );
--5번
SELECT DEPTNO,TO_CHAR(HIREDATE,'YYYY') HIREYEAR , COUNT(*) CNT,
MAX(SAL) MAX_SAL , SUM(SAL) SUM_SAL , AVG(SAL) AVG_SAL
FROM EMP
GROUP BY ROLLUP(DEPTNO,TO_CHAR(HIREDATE,'YYYY'));
'오라클 SQL' 카테고리의 다른 글
오라클 SQL 9강 (0) | 2021.02.26 |
---|---|
오라클 SQL 8강 (0) | 2021.02.26 |
오라클 SQL 6강 연습문제 (0) | 2021.02.26 |
오라클 SQL 7강 (0) | 2021.02.26 |
오라클 SQL 6강 (0) | 2021.02.26 |