来自多个表的聚合不计算

时间:2019-07-02 02:28:17

标签: sql aggregation

我得到了以下选择:

select EN.NAME_COMP, EN.CODE_CODE_COMP, sum(IT.AMOUNT) as TOTAL_AMOUNT
from COMPANY EN, SALARY IT
where IT.NO_ACC = EN.NO_ACC
group by EN.NAME_COMP, EN.CODE_CODE_COMP, IT.AMOUNT
;

sum(IT.AMOUNT)必须​​汇总NAME_COMP的所有金额,但取而代之的是,它分别显示每个NAME_COMP并单独显示金额,而不是总计Sum


NAME_COMP                        CODE_CODE_COMP          TOTAL_AMOUNT 
------------------------------ -------------------- --------------
COMP 1                        23                           1500.5
COMP 1                        23                            500.5
COMP 4                        12                          2100.75

0 个答案:

没有答案