sql 以年月日的方式显示所有员工的服务年限
SELECT ename, hiredate, trunc(MONTHS_BETWEEN(SYSDATE,hiredate) /12) year , trunc(MOD(MONTHS_BETWEEN(SYSDATE,hiredate) , 12 ) ) months , trunc(SYSDATE - ADD_MONTHS(hiredate,months_between(sysdate,hiredate))) day FROM emp ;
SELECT ename, hiredate, trunc(MONTHS_BETWEEN(SYSDATE,hiredate) /12) year , trunc(MOD(MONTHS_BETWEEN(SYSDATE,hiredate) , 12 ) ) months , trunc(SYSDATE - ADD_MONTHS(hiredate,months_between(sysdate,hiredate))) day FROM emp ;