Toolathlon

game-statistics

End-of-day settlement: build leaderboard_YYYYMMDD from the day's top 100 players in daily_scores_stream, and append every player's daily totals to player_historical_stats.

Task Prompt

The end-of-day settlement time for the game has arrived, and we need to process the player score data for the current day in the `daily_scores_stream` table. First, generate the final leaderboard for the day by selecting the top 100 players with the highest scores and storing the results in an independent table named after the day's date, `leaderboard_YYYYMMDD`(Must include player_id, total_score and rank fields). Second, for long-term player behavior analysis, update the statistical data for all players on the day into the master table `player_historical_stats`, inserting a new record for each player containing their ID, the day's date, the day's total score, and the number of games played on the day.