0
我遇到了計算教職員工聘用年數的問題。 (當前時間 - 教師聘請日期)在SQL中計算日期
我想使用這個,但是我總是收到錯誤,DATEDIFF是一個無效的標識符。請幫忙。
SELECT FAC_FN , DATEDIFF ('CURDATE()' , 'FAC_HIRE DATE')
FROM FACULTY;
--CREATING TABLE FACULTY
CREATE TABLE FACULTY
(
FAC_ID NUMBER (4) CONSTRAINT FAC_ID_PK PRIMARY KEY,
FAC_FN VARCHAR2 (15),
FAC_LN VARCHAR2 (15),
FAC_DEPT VARCHAR2 (10),
FAC_RANK VARCHAR2 (10),
FAC_HIRE_DATE DATE,
FAC_SALARY NUMBER (7),
FAC_SUPERVISOR NUMBER (4)
);
--INSERTING RECORDS INTO FACULTY TABLE
INSERT INTO FACULTY VALUES (9001 , 'Leonard' , 'Vince' , 'IS' , 'ASST' , TO_DATE('12-APR-1997','DD-MON-YYYY') , 67000 , 9003);
INSERT INTO FACULTY VALUES (9002 , 'Victor' , 'Strong' , 'CSCI' , 'ASSO' , TO_DATE('8-AUG-1999','DD-MM-YYYY') , 70000 , 9003);
INSERT INTO FACULTY VALUES (9003 , 'Nicki' , 'Colan' , 'IS' , 'PROF' , TO_DATE('20-AUG-1981','DD-MM-YYYY') , 75000, 9010);
INSERT INTO FACULTY VALUES (9004 , 'Fred' , 'Wells' , 'ACCT' , 'ASST' , TO_DATE('28-AUG-1996','DD-MM-YYYY'), 60000, 9010);
INSERT INTO FACULTY VALUES (9010 , 'Chris' , 'Macon' , 'ACCT' , 'ASST' , TO_DATE('4-AUG-1980','DD-MM-YYYY') , 75000 , '');
我正在使用mySQL – user2901565