query_historical_stats
Run read-only SQL queries against the FPL stats database to answer questions about player stats, fixtures, team strength, and gameweek history across seasons.
Instructions
Execute a read-only SQL SELECT against the FPL stats database. Use this to answer questions about player stats, fixtures, team strength, or gameweek history for the seasons in the database.
Available tables (read-only). The current season is fully populated; past seasons
exist only as season totals in players (see notes below the table list):
seasons — id, label (e.g. '2025/26'), start_year, is_current teams — season_id, fpl_id, name, short_name, strength, strength_attack_home/away, strength_defence_home/away gameweeks — season_id, gw_number (1–38), deadline_time, is_current, is_next, is_finished, average_entry_score, highest_score players — season_id, fpl_id, team_fpl_id, first_name, second_name, web_name, position (GKP/DEF/MID/FWD), now_cost, form, total_points, minutes, goals_scored, assists, clean_sheets, expected_goals, expected_assists, ict_index, status, news fixtures — season_id, fpl_id, gw_number, kickoff_time, home_team_fpl_id, away_team_fpl_id, home_score, away_score, finished, home_team_difficulty, away_team_difficulty gw_player_stats — season_id, player_fpl_id, gw_number, fixture_fpl_id, opponent_team_fpl_id, was_home, minutes, goals_scored, assists, clean_sheets, bonus, total_points, expected_goals, expected_assists, ict_index, starts
Notes:
teams, fixtures, gameweeks and gw_player_stats hold the CURRENT season only.
For past seasons,
playershas one row per player per season with season totals (points, minutes, goals, assists, clean sheets, cards, bonus). team_fpl_id is NULL there, and fpl_id is the player's current FPL id. Join seasons for the label.Past seasons only include players in the CURRENT FPL player list. Departed players are absent, so league-wide or team-wide totals for past seasons are incomplete; only trust per-player history for players who appear in the current season.
Join hint: teams.fpl_id = players.team_fpl_id (current season, same season_id).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | A SQL SELECT statement. Only SELECT is allowed — mutations will be rejected. LIMIT is injected automatically if omitted (max 100 rows). |