So I have a table like this:
id mod n1 n2 n3
1 1 1 1
1 2 2
1 3 3
2 1 1
2 2 2
3 1 1
And I want to sum up each value for all the rows for a specific id into a column call total, but I don’t want to group the id together because they have different mod number. I want a result like this:
id mod total
1 1 7
1 2 7
1 3 7
2 1 3
2 2 3
3 1 1
I can’t use group by because it will give me the total for just each individual rows. How do I achieve the result that I want?
You could do something like this:
Not sure about the performance of this though…