当我运行查询时,它会提取所有数据。我只需要提取上个月的数据。也许有一个代码从1月1日到30日读取ACTFINISH日期。
请让我知道上个月数据的代码是什么以及我需要输入的位置。
SELECT WORKORDER.WONUM,
WORKORDER.STATUS,
TO_CHAR(WORKORDER.REPORTDATE,'DD-MON-YY') AS "REPORTDATE",
TO_CHAR(WORKORDER.ACTSTART,'DD-MON-YY') AS "ACTSTART",
TO_CHAR(WORKORDER.ACTFINISH,'DD-MON-YY') AS "ACTFINISH",
WORKORDER.HASCHILDREN,
WORKORDER.ACTLABCOST,
WORKORDER.ACTMATCOST,
WORKORDER.ACTTOOLCOST,
WORKORDER.WORKTYPE,
WORKORDER.DESCRIPTION,
WORKORDER.ACTSERVCOST,
WORKORDER.EXT_DISTWORKTYPE,
WORKORDER.LOCATION,
MAXPRD.LOCATIONS.EXT_OFFICE,
MAXPRD.LOCATIONS.EXT_STATECODE,
WORKORDER.OWNERGROUP,
CASE MAXPRD.LOCATIONS.EXT_SRV_POLYGON
WHEN 'BOF'
THEN 'GAS'
WHEN 'CDA'
THEN 'GAS'
WHEN 'COL'
THEN 'GAS'
WHEN 'DAV'
THEN 'GAS'
WHEN 'GOS'
THEN 'GAS'
WHEN 'KEL'
THEN 'GAS'
WHEN 'KLF'
THEN 'GAS'
WHEN 'LAG'
THEN 'GAS'
WHEN 'LEC'
THEN 'GAS'
WHEN 'MED'
THEN 'GAS'
WHEN 'PUM'
THEN 'GAS'
WHEN 'RIT'
THEN 'GAS'
WHEN 'ROS'
THEN 'GAS'
WHEN 'SAN'
THEN 'GAS'
WHEN 'SPO'
THEN 'GAS'
ELSE 'ELECTRIC'
END AS TYPE,
TO_CHAR(WORKORDER.SCHEDSTART,'DD-MON-YY') AS SCHEDSTART,
TO_CHAR(WORKORDER.SCHEDFINISH,'DD-MON-YY') AS SCHEDFINISH,
TO_CHAR(WORKORDER.TARGCOMPDATE,'DD-MON-YY') AS TARGCOMPDATE,
TO_CHAR(WORKORDER.TARGSTARTDATE,'DD-MON-YY') AS TARGSTARTDATE
FROM WORKORDER
INNER JOIN MAXPRD.LOCATIONS
ON WORKORDER.LOCATION = MAXPRD.LOCATIONS.LOCATION
WHERE WORKORDER.STATUS IN ('COMP', 'CLOSE')
AND WORKORDER.SITEID = 'OPS'
答案 0 :(得分:2)
听起来你只是想要
actfinish
如果您要使用的and actfinish >= trunc(add_months(sysdate,-1),'MM')
and actfinish < trunc(sysdate,'MM')
上有索引
{{1}}
答案 1 :(得分:-1)
只需在where子句中添加条件即可。你应该可以使用这样的东西
$timeout