需要sqlplus查询帮助,执行时收到错误

时间:2017-12-25 07:08:40

标签: sql oracle

我在下面做错了什么?

select D_OPERATION_DATE, count(*)
from 
(select to_char(D_OPERATION_DATE, 'MON') D_OPERATION_DATE, SUM (N_OPERATION_FEE) from SBM_BILLING_RESULT where c_operation_type='Commit' and C_RESULT_STATUS='SUCCESS')
group by D_OPERATION_DATE;
  

错误:   ORA-00937:不是单组组功能   00937. 00000 - “不是单组小组的功能”   *原因:
  *行动:   行错误:13列:17

任何线索?

1 个答案:

答案 0 :(得分:1)

您在内部语句中使用'sum()'与单个列名'to_char(D_OPERATION_DATE,'MON')'。 在这种情况下,你需要'GROUP BY to_char(D_OPERATION_DATE,'MON')'到内部语句的结尾。

    select D_OPERATION_DATE, count(*) 
from (
    select to_char(D_OPERATION_DATE, 'MON') D_OPERATION_DATE, SUM (N_OPERATION_FEE) 
    from SBM_BILLING_RESULT 
    where c_operation_type='Commit' and C_RESULT_STATUS='SUCCESS' 
    GROUP BY to_char(D_OPERATION_DATE, 'MON')
    )
group by D_OPERATION_DATE;