I have a table
id index value
1 1 2
2 1 3
3 2 6
4 3 8
I can do like this:
select sum(value) from table group by index
But what I want is that each row can go to multiple groups, pseudocode
select sum(value) from table group by >= index
Basically the indexes are 1,2,3 and I want it to group these into 3 seperate groups.
- Sum of values where index is bigger/equal than 1
- Sum of values where index is bigger/equal than 2
- Sum of values where index is bigger/equal than 3
This must be a generic function, so I actually would not know the index level, as it is hardcoded here.
This is example output:
indexLevelBiggerEquals sumValue
1 19 -- sum of all rows that are >= 1
2 14 -- sum of all rows that are >= 2
3 8 -- sum of all rows that are >= 3