A
SELECT DEPTNO, FLOOR(AVG(SAL)) as AVG_SAL, MAX(SAL) as MAX_SAL, MIN(SAL) as MIN_SAL, COUNT(DEPTNO) as CNT FROM EMP GROUP BY DEPTNO;
A
SELECT JOB, COUNT(*) FROM EMP GROUP BY JOB HAVING COUNT(*) >= 3;
A
SELECT SUBSTR(HIREDATE, 1, 4) as HIRE_YEAR, DEPTNO, COUNT(*) as CNT FROM EMP GROUP BY SUBSTR(HIREDATE, 1, 4), DEPTNO;
A
SELECT CASE WHEN COMM = NULL THEN 'X' WHEN COMM > 0 THEN 'O' ELSE 'X' END as EXIST_COMM, COUNT(*) as CNT FROM EMP GROUP BY CASE WHEN COMM = NULL THEN 'X' WHEN COMM > 0 THEN 'O' ELSE 'X' END;
A
SELECT DEPTNO, SUBSTR(HIREDATE, 1, 4) as HIRE_YEAR, COUNT(*) as CNT,MAX(SAL) as MAX_SAL, SUM(SAL) as SUM_SAL, AVG(SAL) as AVG_SAL FROM EMP GROUP BY ROLLUP(DEPTNO, SUBSTR(HIREDATE, 1, 4)) ORDER BY DEPTNO;