It is not much more complicated. Need to add the Period id to qryMatches, and modify the aggregate query to then group on the Period to make the query "qryTeamStatsByPeriod". Then the update temp table code needs to get modified to handle tie groups by period and ranking by period. Not too complicated, but you are adding one more loop and there are three already so it may be a little confusing to code.
I will try to do an update. Also for the temp table I am not going to add in all of the other statistics fields except these.
tempTblRankings
tempTblRankings
PeriodID_FK | Rank | TeamID | TieGroup | TotalPointsTieGroup | GoalBalanceTieGroup |
---|
1 | | 1 | | | |
These are the only fields needed in the Temp table. The other statistic fields can come directly from the original query they do not need to be copied over. Subtle difference, but this way gives more chance of all the other fields being current because they are calculated dynamic from the queries, even if your application has not yet run the temptable update. If not you may have to run the code to ensure you can see your updated stats. Adding and deleting from a temp table can cause bloating, so you want to limit running the update only when you have new data to change the ranks. (there are other things you can do to limit this. Fixed by compacting and repairing).