if you're handy with SQL you could probably do the sum(s) right in your database when you query it for your data...if i could see the SQL you're using now to pull the data out i could likely be more specific.
"Whom are you?" said he, for he had been to night school.
-- George Ade
"A long memory is the most subversive idea in America."