我有这样的 statement言:
select a.id, a.valfrom ...
inner join ...
where ...;
因此,我:
id val
---------
3 10
3 10
3 10
9 21
9 21
11 2
11 2
13 30
因此,你可以看到,一个人的补贴具有一个价值。
如果我由(a.id)组成一个小组,我会:
id val
---------
3 10
9 21
11 2
13 30
What I want to get of the last result is the sum: 10+21+2+30 = 63.
So how can I get the sum as a single result? If I do a sum(a.val) and use group by (a.id) I do not get 63, I get the sum for every id, for example id=3 -> 10+10+10 = 30.
最佳方面。