我有一个查询,我正在比较两个日期以获取数据。以下是相同的查询:
SELECT CIRCLE, MPNAME AS ITEM,
ROUND(SUM(INTER_FSA_UG),2) INTER_UG, ROUND(SUM(INTER_FSA_AERIAL),2) INTER_AR,
ROUND(SUM(INTRA_FSA_UG),2) INTRA_UG, ROUND(SUM(INTRA_FSA_AERIAL),2) INTRA_AR,
ROUND(SUM(ENTER_FSA_UG),2) ENTER_UG, ROUND(SUM(ENTER_FSA_AERIAL),2) ENTER_AR
FROM (
SELECT CIRCLE, MAINTENANCEZONENAME AS MPNAME,
SUM(case when SPAN_TYPE= 'INTERCITY' then NE_LENGTH else 0 end )as INTER_NE_LENGTH ,
SUM(case when SPAN_TYPE= 'INTRACITY' then NE_LENGTH else 0 end )as INTRA_NE_LENGTH,
SUM(case when SPAN_TYPE= 'ENTERPRISE' then NE_LENGTH else 0 end )as ENTER_NE_LENGTH,
SUM(case when SPAN_TYPE= 'INTERCITY' then FSA_UG else 0 end )as INTER_FSA_UG,
SUM(case when SPAN_TYPE= 'INTRACITY' then FSA_UG else 0 end )as INTRA_FSA_UG,
SUM(case when SPAN_TYPE= 'ENTERPRISE' then FSA_UG else 0 end )as ENTER_FSA_UG,
SUM(case when SPAN_TYPE= 'INTERCITY' then FSA_AERIAL else 0 end )as INTER_FSA_AERIAL,
SUM(case when SPAN_TYPE= 'INTRACITY' then FSA_AERIAL else 0 end )as INTRA_FSA_AERIAL,
SUM(case when SPAN_TYPE= 'ENTERPRISE' then FSA_AERIAL else 0 end )as ENTER_FSA_AERIAL
FROM TBL_FIBER_INV_SIGN_OFF_SHEET_H
WHERE
UPPER(CIRCLE) = UPPER(STATENAME)
--HOTOOFFERDATE >= TO_DATE('11'||PHOTODATE,'DDMMYYYY') TO_DATE('11-04-23','DD-MM-YY');
AND TO_CHAR( TO_DATE(HOTOOFFERDATE,'DD-MM-YY, HH:MI:SS') ,'MMYYYY') = TO_CHAR(PHOTODATE,'MMYYYY') // here is the error
GROUP BY CIRCLE, MAINTENANCEZONENAME, SPAN_TYPE
ORDER BY MAINTENANCEZONENAME
) GROUP BY CIRCLE, MPNAME ORDER BY MPNAME;
注意 我的
HOTOOFFERDATE
是 DATE 数据类型,PHOTODATE
是 NVARCHAR2。
导致错误的原因是什么以及如何修复它?
尝试 TO_CHAR(TO_DATE(HOTOOFFERDATE,'DD-MM-YY, HH:MI:SS') ,'MMYYYY') = TO_CHAR(TO_DATE(PHOTODATE,'DD-MM-YY'),'MMYYYY')