WITH data1 AS ( SELECT dwdm, ny, wfqyzt, bz count( decode( qdrq, '2023', 1 ) ), count( decode( qdrq, '2022', 1 ) ), sum( decode( qdrq, '2022', bdje, 0 ) ), sum( decode( qdrq, '2023', bdje, 0 ) ), sum( decode( qdrq, '2022', skje, 0 ) ), sum( decode( qdrq, '2022', skje, 0 ) ), sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '1' THEN bdje ELSE 0 END ) AS YGFW sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '2' THEN bdje ELSE 0 END ) AS YDRH sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '3' THEN bdje ELSE 0 END ) AS KQFW sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '4' THEN bdje ELSE 0 END ) AS XQJY sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '5' THEN bdje ELSE 0 END ) AS YLWS sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '6' THEN bdje ELSE 0 END ) AS JMSW sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB IN ( '7', '8' ) THEN bdje ELSE 0 END ) AS WCSC sum( CASE WHEN JFDWLB IN ( '2' ) THEN bdje ELSE 0 END ) AS FGS CASE WHEN JFDWLB IN ( '1' ) THEN bdje ELSE 0 END ) AS GLJ FROM A_YDSB_ZXFX001 WHERE qdrq IN ( substr( '202306', 0, 4 ) - 1, '2023' ) ) data2 AS ( SELECT * FROM A_YDSB_ZXFX002 ) SELECT a.*, b.dwdm, b.ny, b.wfqyzt FROM data1 a LEFT JOIN data2 b ON a.dwdm = b.dwdm WHERE NY = '202306' AND DWDM = '50300017' ORDER BY DWDM 提示ORA-00923: 未找到要求的 FROM 关键字该怎么修改
时间: 2023-08-20 13:06:39 浏览: 148
您好!根据您提供的SQL查询语句,根据错误提示,看起来是缺少了一个必要的 FROM 关键字。请尝试在以下位置添加一个 FROM 关键字:
```sql
WITH data1 AS (
SELECT
dwdm,
ny,
wfqyzt,
bz count( decode( qdrq, '2023', 1 ) ),
count( decode( qdrq, '2022', 1 ) ),
sum( decode( qdrq, '2022', bdje, 0 ) ),
sum( decode( qdrq, '2023', bdje, 0 ) ),
sum( decode( qdrq, '2022', skje, 0 ) ),
sum( decode( qdrq, '2022', skje, 0 ) ),
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '1' THEN bdje ELSE 0 END ) AS YGFW,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '2' THEN bdje ELSE 0 END ) AS YDRH,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '3' THEN bdje ELSE 0 END ) AS KQFW,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '4' THEN bdje ELSE 0 END ) AS XQJY,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '5' THEN bdje ELSE 0 END ) AS YLWS,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB = '6' THEN bdje ELSE 0 END ) AS JMSW,
sum( CASE WHEN JFDWLB IN ( '3', '4', '5', '6' ) AND XTFWYWLB IN ( '7', '8' ) THEN bdje ELSE 0 END ) AS WCSC,
sum( CASE WHEN JFDWLB IN ( '2' ) THEN bdje ELSE 0 END ) AS FGS,
CASE WHEN JFDWLB IN ( '1' ) THEN bdje ELSE 0 END
FROM
A_YDSB_ZXFX001
WHERE
qdrq IN ( substr( '202306', 0, 4 ) - 1, '2023' )
), data2 AS (
SELECT * FROM A_YDSB_ZXFX002
)
SELECT
a.*,
b.dwdm,
b.ny,
b.wfqyzt
FROM
data1 a
LEFT JOIN
data2 b ON a.dwdm = b.dwdm
WHERE
NY = '202306'
AND DWDM = '50300017'
ORDER BY
DWDM;
```
请注意,这只是一个基于您提供的信息的修改建议,如果问题还存在,请提供更多的上下文信息,以便我能够更好地帮助您解决问题。
阅读全文