You probably need an array for that. 1 dimension should be enough.
When the star progress is saved, instead of saving them to a global variable, save them to the array.
Set Array at (level-1) = stars (with the condition that stars > array at (level-1))
This way each level got his "stars obtained"-number saved in the array and it only increases if you obtain more stars in the level than last time. Make sure to set the width of the array to the number of levels you have.
And to obtain the total stars obtained over all levels:
-(some event that triggers the total stars counting)
--subevent: set totalstars(globalvariable) to 0
--another subevent: array->for each element (X) -> add to totalstars: array.curvalue