select RECIPE_DEPT_ID,RECIPE_DEPT_NAME,RECIPE_DOCT_ID,RECIPE_DOCT_NAME,EXECUTE_DEPT_ID,EXECUTE_DEPT_NAME,EXECUTE_DOCT_ID,EXECUTE_DOCT_NAME,ITEM_CLASS_ID,ITEM_CLASS_NAME,ITEM_ID,ITEM_NAME,ITEM_PRICE,SUM(AMOUNT)AMOUNT,SUM(COSTS)COSTS,TO_DATE('2023-05-01 00:00:00','YYYY-MM-DD HH24:MI:SS')OPER_TIME from I_OP_EXP_CHARGE_DETAIL where OPER_TIME between TO_DATE('2023-05-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_DATE('2023-05-31 23:59:59','YYYY-MM-DD HH24:MI:SS')and AMOUNT<>0 or COSTS <>0 GROPU BY RECIPE_DEPT_ID,RECIPE_DEPT_NAME,RECIPE_DOCT_ID,RECIPE_DOCT_NAME,EXECUTE_DEPT_ID,EXECUTE_DEPT_NAME,EXECUTE_DOCT_ID,EXECUTE_DOCT_NAME,ITEM_CLASS_ID,ITEM_CLASS_NAME,ITEM_ID,ITEM_NAME,ITEM_PRICE 这段代码报sql命令未正确结束,帮我看看什么原因
时间: 2023-09-22 15:08:59 浏览: 134
p_video_state.rar_In Motion
在你提供的查询代码中,存在一个错误:GROPU BY 应该是 GROUP BY。请改正这个拼写错误,将 "GROPU BY" 改为 "GROUP BY",即可解决问题。以下是已更正的代码示例:
```sql
SELECT
RECIPE_DEPT_ID, RECIPE_DEPT_NAME, RECIPE_DOCT_ID, RECIPE_DOCT_NAME,
EXECUTE_DEPT_ID, EXECUTE_DEPT_NAME, EXECUTE_DOCT_ID, EXECUTE_DOCT_NAME,
ITEM_CLASS_ID, ITEM_CLASS_NAME, ITEM_ID, ITEM_NAME, ITEM_PRICE,
SUM(AMOUNT) AS AMOUNT, SUM(COSTS) AS COSTS,
TO_DATE('2023-05-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') AS OPER_TIME
FROM
I_OP_EXP_CHARGE_DETAIL
WHERE
OPER_TIME BETWEEN TO_DATE('2023-05-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE('2023-05-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
AND (AMOUNT <> 0 OR COSTS <> 0)
GROUP BY
RECIPE_DEPT_ID, RECIPE_DEPT_NAME, RECIPE_DOCT_ID, RECIPE_DOCT_NAME,
EXECUTE_DEPT_ID, EXECUTE_DEPT_NAME, EXECUTE_DOCT_ID, EXECUTE_DOCT_NAME,
ITEM_CLASS_ID, ITEM_CLASS_NAME, ITEM_ID, ITEM_NAME, ITEM_PRICE;
```
请注意,在上述示例中,我还添加了别名来标识聚合函数的结果(SUM(AMOUNT) AS AMOUNT, SUM(COSTS) AS COSTS)。这样可以更清晰地表示查询结果。如果还有其他问题,请随时提问。
阅读全文