Let's say I have a table
as the following:
LogicalRef Code Balance
1 320.01 11.5
2 320.01 9
3 320.01.03 10
4 320.02 7
5 320.03 0
6 320.03.01 3
7 320.03.01 4
I want to get the distinct codes and the sums for each code such that the sum of the sub-groups are added to the main groups. Hence, the SELECT Code, SUM(Balance) FROM table GROUP BY Code
does not work.
I want to get the following table:
Code SUM
320.01 30.5
320.01.03 10
320.02 7
320.03 7
320.03.01 7
I guess there has to be something with LIKE Code + '%'
, but I could not find any solution up to now. Any help would be appreciated.
Thanks!