早上好,亲爱的团队。我需要有关以下失败的 Oracle SQL 查询的帮助。 我需要使用变量进行计算,并且我在案例财产中收到以下错误。
“[错误]执行(2:1):ORA-00900:无效的SQL语句” 错误:第 9 行第 13 列,第 9 行第 16 列结束:在期待 FROM 时找到
DEFINE HRESP_MX = 0
SELECT
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY' ) AS DATET,
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY HH24' ) AS TIMET,
CRD_FIID,
MAX ( (sysdate + (RE_ENTRY_TIM - EXIT_TIM)*24*60*60 - sysdate) ) INTO HRESP_MX,
CASE WHEN ( HRESP_MX BETWEEN 0,000 and 0,200 ) THEN 'R-02'
WHEN ( HRESP_MX BETWEEN 0,201 and 0,300 ) THEN 'R0.2'
WHEN ( HRESP_MX BETWEEN 0,301 and 0,400 ) THEN 'R0.3'
WHEN ( HRESP_MX BETWEEN 0,401 and 0,500 ) THEN 'R0.4'
WHEN ( HRESP_MX BETWEEN 0,501 and 1,000 ) THEN 'R0.0'
WHEN ( HRESP_MX BETWEEN 1,001 and 1,500 ) THEN 'R1.0'
WHEN ( HRESP_MX BETWEEN 1,501 and 2,000 ) THEN 'R1.5'
WHEN ( HRESP_MX BETWEEN 2,001 and 2,500 ) THEN 'R2.0'
WHEN ( HRESP_MX BETWEEN 2,501 and 3,000 ) THEN 'R2.5'
WHEN ( HRESP_MX BETWEEN 3,001 and 3,500 ) THEN 'R3.0'
WHEN ( HRESP_MX BETWEEN 3,501 and 4,000 ) THEN 'R3.5'
WHEN ( HRESP_MX BETWEEN 4,001 and 4,500 ) THEN 'R4.0'
WHEN ( HRESP_MX BETWEEN 4,501 and 5,500 ) THEN 'R4.5'
ELSE 'R5.0' END
FROM ORACLE.File_r6
WHERE ( DAT_TIM BETWEEN '05/09/2024 05:11:00' AND '05/09/2024 05:58:59') and
( Resp_Cde <> '206' ) and
( TYP IN ( '0210', '0220' ) ) and
( RESPONDER IN ( '5' ) ) and
( TRAN_CDE_TC <> '50' )
GROUP BY
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY' ),
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY HH24' ),
CRD_FIID,
( (sysdate + (RE_ENTRY_TIM - EXIT_TIM)*24*60*60 - sysdate) )
ORDER by
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY' ),
TO_CHAR( CAST ( ENTRY_TIM AS DATE ), 'DD-MM-YYYY HH24' ),
CRD_FIID;
CASE WHEN
做
CASE X WHEN
然后X将获得值,例如'R-02'