I have the following scenario
pid & month form a composite primary key .
pid month amount
1 1 10
2 2 15
1 2 20
1 3 10
3 3 4
2 3 6
Now the column to be generated with the table will be like this
pid month amount sum
1 1 10 10
2 2 15 15
1 2 20 30
1 3 10 40
3 3 4 4
2 3 6 21
What should be the query ?