1

我想计算支出总额并从这样的行数计算平均值:

SELECT AVG(SUM(expenditure)) from INCOME;

但是,有一个错误说“滥用聚合函数 sum()”

我怎样才能做到这一点?

4

2 回答 2

3

您无法计算总和的平均值,因为只有一个总数。

作为其逻辑的一部分, averageAVG()函数已经计算了总数。

这就是你想要的:

SELECT AVG(expenditure) as AverageExpenditure, 
       SUM(expenditure) as TotalExpenditure
from INCOME;
于 2013-03-05T02:53:38.360 回答
2
SELECT AVG(expenditure) AS avg_exp, SUM(expenditure) AS sum_exp FROM INCOME;
于 2013-03-05T02:52:43.867 回答