怎样用access时间查询提前一天,
在面页面中输入2007-11,查询的是2007-11-16 0:00到2007-12-15 0:00的数据,现在要提前一天,就是输入2007-11,查询的是2007-11-15 0:00到2007-12-14 0:00的数据.我的语句:
SELECT B.EMP_NAME,B.DEPT_NAME,A.*
FROM (SELECT A.*,B.* FROM
(SELECT EMP_CODE,MONTH,SUM(CDA) AS SCDA,SUM(CDB) AS SCDB,SUM(CDC) AS SCDC,SUM(ZT) AS SZT,
SUM(BJA) AS SBJA,SUM(BJB) AS SBJB,SUM(SJ) AS SSJ,SUM(KG) AS SKG
FROM EMP_KQ WHERE MONTH='2006-11' GROUP BY EMP_CODE,MONTH) A
LEFT OUTER JOIN KQ_EXT B ON A.EMP_CODE=B.EMPCODE AND A.MONTH=B.MONTH) A
RIGHT OUTER JOIN (SELECT C.EMP_NAME,C.EMP_CODE,D.DEPT_CODE,D.DEPT_NAME FROM EMP_BASE C,DEPT D
WHERE D.DEPT_CODE=C.EMP_DEPT AND C.EMP_TYPE='R01') B ON A.EMP_CODE=B.EMP_CODE
ORDER BY B.DEPT_CODE,B.EMP_CODE ASC
參考答案:在SQL中用使用 datediff 函数