-1

This is my sum clause

Select *,(sum(current_bal-curr_bal_now)/ 
current_bal from base
Group by month

This gives me an error because I'm not using current_bal in the group by. Is there a way of not using group by current_bal aswell as month as it completely messes up the output layout.

Thanks

4

2 回答 2

1

另一个猜测...

SELECT *,
       ( sum(current_bal) OVER (PARTITION BY month) ) / current_bal
FROM   base 
于 2012-09-19T15:23:06.073 回答
0

问题是总和只会返回一个值,因此,在您的所有选择中,Current_bal是不同的。应该选择哪一个?

如果您想要添加每个部门,如下所示:

Select sum(current_bal/current_bal)
from base
Group by month

将工作

于 2012-09-19T15:21:10.167 回答