--6강 연습문제
--1번
SELECT EMPNO , RPAD(SUBSTR(EMPNO,1 ,2 ),LENGTH(EMPNO),'*') MASKING_EMPNO , ENAME , RPAD(SUBSTR
(ENAME,1,1),LENGTH(ENAME),'*') MASKING_ENAME
FROM EMP
WHERE LENGTH(ENAME) >=5 AND LENGTH(ENAME) < 6 ;
--2번
SELECT EMPNO , ENAME , SAL , TRUNC(SAL/21.5,2) DAY_PAY , ROUND(SAL/21.5/8,1) TIME_PAY
FROM EMP;
--3번
SELECT EMPNO,ENAME , TO_CHAR(HIREDATE,'YYYY/MM/DD') HIREDATE , TO_CHAR(NEXT_DAY(ADD_MONTHS(HIREDATE,3),'월'),'YYYY-MM-DD') R_JOB ,
NVL2(COMM,TO_CHAR(COMM),'N/A') AS COMM FROM EMP;
--4번
SELECT EMPNO, ENAME, MGR,
CASE WHEN MGR IS NULL THEN '0000'
WHEN SUBSTR(MGR,1,2)='75' THEN '5555'
WHEN SUBSTR(MGR,1,2)='76' THEN '6666'
WHEN SUBSTR(MGR,1,2)='77' THEN '7777'
WHEN SUBSTR(MGR,1,2)='78' THEN '8888'
ELSE TO_CHAR(MGR)
END AS CHG_MGR
FROM EMP;
'오라클 SQL' 카테고리의 다른 글
오라클 SQL 8강 (0) | 2021.02.26 |
---|---|
오라클 SQL 7강 연습문제 (0) | 2021.02.26 |
오라클 SQL 7강 (0) | 2021.02.26 |
오라클 SQL 6강 (0) | 2021.02.26 |
오라클 SQL 4~5강 (0) | 2021.02.26 |