Months_Between/Add_Months/Last_Day
Select ename, round(Months_Between(Sysdate,Hiredate))from employee; Select Ename,Hiredate, Add_Months(Hiredate,6), Add_Months(Hiredate,-6)from employee; Select Sysdate, Next_Day(Sysdate,1) -- 1~7 (月~日)from dual; Select Hiredate, Last_Day(Hiredate)From employee;
더보기
DECODE / CASE WHEN
DECODE 는 equal연산 밖에 안된다.equal이외의 연산을 사용할때엔 CASE WHEN을 사용한다. .DECODESelect Ename, Dno, Decode(Dno, 10,'ACCOUNTING', 20,'Research', 30,'sales', 40,'operations', 'Default') As DnameFrom Employeeorder by dno; default값을 설정하지 않으면 null이 설정된다.디폴트값을 입력하도록 해주자..( 오류의 위험.) Select Ename, Dno, Case When Dno >= 40 Then 'OPERATIONS' When Dno >= 30 Then 'SALES' When Dno >= 20 Then 'RESEARCH' When Dno >= 10 Then..
더보기