I wrote something on sub-totalling with aggregates a few years ago - there might be something there to explain it to you. Take a look at this:
https://openacs.org/blog/one-entry?entry_id=907364
Brian