I have a sql statement:
select a.id, a.valfrom ...
inner join ...
where ...;
As a result, I have the following:
id val
---------
3 10
3 10
3 10
9 21
9 21
11 2
11 2
13 30
So, you can see, one identifier has one value.
If I do a group on (a.id), I get:
id val
---------
3 10
9 21
11 2
13 30
What I want to get from the last result is the sum: 10 + 21 + 2 + 30 = 63.
So how can I get the amount as a single result? If I do the sum (a.val) and use the group by (a.id), I do not get 63, I get the sum for each id, for example id = 3 β 10 + 10 + 10 = 30.
Regards.
source
share