ORA-00979:sum(col)时不是GROUP BY表达式

时间:2015-07-30 08:32:10

标签: oracle group-by sum

SELECT 
    INVOICEM.EMP_NO,
    EMPLOYEES.EMP_NAME,
    INVOICEM.INV_NO,
    SUM(INVOICEM.SUM_AMT),
    INVOICEM.SAL_DATE,
    INVOICEM.BRANCH
FROM INVOICEM JOIN EMPLOYEES
ON INVOICEM.EMP_NO = EMPLOYEES.EMP_NO
GROUP BY INVOICEM.EMP_NO,EMP_NAME

帮帮我

1 个答案:

答案 0 :(得分:0)

您只能在oracle中选择分组语句或聚合函数的字段:

SELECT INVOICEM.EMP_NO,EMPLOYEES.EMP_NAME,SUM(INVOICEM.SUM_AMT)
FROM INVOICEM JOIN EMPLOYEES
ON INVOICEM.EMP_NO = EMPLOYEES.EMP_NO
GROUP BY INVOICEM.EMP_NO,EMP_NAME