我正在为 Oracle SQL Dev 中的 Crystal 报表编写命令,但遇到了问题。我的用户希望有允许他们使用格式为“yyyymm”的起始年份/期间和结束参数相同的参数。我发生的问题是,使用这些参数他们还想从 2012 财年到 2013 财年和第 10 期(从 2012 财年)到第 06 期(从 2013 财年)如何设置我的命令来处理这个? 以下是我目前正在处理表、视图、API 等的一些代码,出于安全目的,它们的名称已更改:
SELECT SOO.PART_NO,
AP.ACCOUNTING_YEAR,
AP.ACCOUNTING_PERIOD,
INVENTORY_PART_API.GET_DESCRIPTION(SOO.CONTRACT, SOO.PART_NO) AS PART_DESCRIPTION,
SUM(SO.QTY_COMPLETE) AS QTY_COMP,
MAX(PART_COST_API.GET_TOTAL_ACCUM_COST(SOO.CONTRACT,SOO.PART_NO,'1','*','*')) AS TOTAL_ACCUM_COST,
MAX(ORA_DATABASE_NAME) AS ORA_DATABASE_NAME
FROM SHOP_ORDER_OPERATION_TAB SOO
LEFT JOIN ACCOUNTING_PERIOD_TAB AP
ON SOO.CONTRACT = '09'
AND SOO.OPER_STATUS_CODE = '90'
AND SOO.CONTRACT = AP.COMPANY
AND SOO.LAST_ACTIVITY_DATE BETWEEN AP.DATE_FROM AND AP.DATE_UNTIL
LEFT JOIN SHOP_ORD SO
ON SOO.CONTRACT = '09'
AND SOO.OPER_STATUS_CODE = '90'
AND SO.ORDER_NO = SOO.ORDER_NO
AND SO.RELEASE_NO = SOO.RELEASE_NO
AND SO.SEQUENCE_NO = SOO.SEQUENCE_NO
AND SO.CONTRACT = SOO.CONTRACT
WHERE SOO.CONTRACT = '09'
AND SOO.OPER_STATUS_CODE = '90'
AND NVL(AP.ACCOUNTING_PERIOD,0) BETWEEN SUBSTR('201205',5,2) AND SUBSTR('201306',5,2)
AND NVL(AP.ACCOUNTING_YEAR,0) BETWEEN 2012 AND 2013
GROUP BY SOO.CONTRACT,
SOO.PART_NO ,
AP.ACCOUNTING_YEAR,
AP.ACCOUNTING_PERIOD
ORDER BY
AP.ACCOUNTING_PERIOD ASC,
AP.ACCOUNTING_YEAR ASC,
SOO.PART_NO ASC;