Acts_as_versioned - summing prior records

We have a table of users, each user having a monthly “goal” number. As a
company, we need a snapshot of the combined goal of all users. However,
we also need to be able to go back in time and see what a goal was for a
specific month. Since our “users” table is versioned, I know the data is
there.

However, for a specific date, I’m having trouble avoiding a separate
query for each user’s goal, mainly because there are many other fields
in the users table causing each user to have multiple versions within a
month. So if user A has 10 different versions for January, summing up
the goals for January will count that user’s goal 10 times.

Any suggestions? Thank you!