Skip to content

MLB

MLB standings, schedules, box scores and player statistics

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/mlb/index.md to help me query MLB with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Current division tables in official rank order.

Example output · captured
Connector release
v0.5.1
Engine
2.0.1
VGI protocol
3.4.0
SELECT division_name, division_rank, team_name, wins, losses, games_back
FROM mlb.main.current_standings
ORDER BY division_name, division_rank
Result · first 5 rows
division_name division_rank team_name wins losses games_back
American League Central 1 Cleveland Guardians 85 77 0
American League Central 2 Chicago White Sox 84 78 1
American League Central 3 Minnesota Twins 77 85 8
American League Central 4 Detroit Tigers 76 86 9
American League Central 5 Kansas City Royals 69 93 16

Quick start

Choose where to run MLB, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'mlb' AS mlb (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-mlb'
);

3. Run a query

query.sql
SELECT division_name, division_rank, team_name, wins, losses, games_back
FROM mlb.main.current_standings
ORDER BY division_name, division_rank
More example queries →
Technical details
Verified connector release
v0.5.1
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'mlb' AS mlb (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-mlb'
);

Overview

Read-only Major League Baseball standings and player statistics from MLB's Stats API

Catalog

Everything mlb exposes once attached — read straight from the worker's released build.

mlb 1 schema
main 4 tables · 16 functions

Current and historical MLB standings

Schema examples (6)
Examples (6)

Current division tables in official rank order.

SELECT division_name, division_rank, team_name, wins, losses, games_back
FROM mlb.main.current_standings
ORDER BY division_name, division_rank;
Result · first 5 rows
division_name division_rank team_name wins losses games_back
American League Central 1 Cleveland Guardians 85 77 0
American League Central 2 Chicago White Sox 84 78 1
American League Central 3 Minnesota Twins 77 85 8
American League Central 4 Detroit Tigers 76 86 9
American League Central 5 Kansas City Royals 69 93 16

Teams with the best run differential.

SELECT team_name, wins, losses, run_differential
FROM mlb.main.current_standings
ORDER BY run_differential DESC;

Each 2025 division winner's lowest-ERA qualified pitcher, joining standings() to pitching_stats() on team_id (pitchers traded mid-season have no team_id and are excluded).

SELECT s.division_name, s.team_name, s.wins, p.player_name,
  p.innings_pitched, p.strikeouts, p.era
FROM mlb.main.standings(season := 2025) s
JOIN mlb.main.pitching_stats(season := 2025, qualified_only := true) p ON p.team_id = s.team_id
WHERE s.division_rank = 1
QUALIFY row_number() OVER (PARTITION BY s.team_id ORDER BY p.era, p.player_id) = 1
ORDER BY s.division_name;

2025 hitters with at least 50 plate appearances who also pitched, joining batting_stats() to pitching_stats() on player_id; mostly position players in mop-up relief, led by two-way Shohei Ohtani.

SELECT b.player_name, b.position_abbreviation, b.plate_appearances, b.ops,
  p.games_pitched, p.innings_pitched, p.era
FROM mlb.main.batting_stats(season := 2025) b
JOIN mlb.main.pitching_stats(season := 2025) p USING (player_id)
WHERE b.plate_appearances >= 50
ORDER BY p.games_pitched DESC, b.player_name
LIMIT 20;
2 more examples

2025 shortstops with at least 2,400 defensive outs (800 innings) at the position, ranked by OPS alongside their errors and fielding percentage there.

SELECT f.player_name, f.last_team_abbreviation, f.outs, f.errors,
  f.fielding_percentage, b.plate_appearances, b.ops
FROM mlb.main.fielding_stats(season := 2025) f
JOIN mlb.main.batting_stats(season := 2025) b USING (player_id)
WHERE f.position_abbreviation = 'SS' AND f.outs >= 2400
ORDER BY b.ops DESC, f.player_id
LIMIT 10;

Shohei Ohtani's 2025 batting split by whether the opponent finished at .500 or better, joining his batting_game_log() to the final standings() on opponent_id.

SELECT s.winning_percentage >= 0.500 AS opponent_500_or_better,
  count(*) AS games, sum(g.at_bats) AS at_bats, sum(g.hits) AS hits,
  sum(g.home_runs) AS home_runs,
  round(sum(g.hits) / sum(g.at_bats), 3) AS batting_average
FROM mlb.main.batting_game_log(660271, season := 2025) g
JOIN mlb.main.standings(season := 2025) s ON s.team_id = g.opponent_id
GROUP BY ALL
ORDER BY opponent_500_or_better;
Tables
current_batting 1 example49 cols

Current-season batting statistics, one row per MLB player

Columns
season INTEGER
MLB season year.
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason.
player_idnot null INTEGER
Stable MLB player identifier.
player_name VARCHAR
Player's full name.
age INTEGER
Player age reported for this statistical season.
birth_date DATE
Player birth date.
primary_number VARCHAR
Uniform number, when available.
position_code VARCHAR
MLB position code.
position_name VARCHAR
Position name.
position_abbreviation VARCHAR
Position abbreviation.
bats VARCHAR
Batting side code: L, R, or S.
throws VARCHAR
Throwing-hand code: L or R.
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals.
team_name VARCHAR
Team represented by this row; NULL for multi-team totals.
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals.
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals.
last_team_name VARCHAR
Last or current team MLB associates with the player.
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team.
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL.
league_name VARCHAR
League name.
league_abbreviation VARCHAR
League abbreviation, AL or NL.
num_teams INTEGER
Number of teams represented by this aggregate split.
num_leagues INTEGER
Number of leagues represented by this aggregate split.
games_played INTEGER
Games played.
plate_appearances INTEGER
Plate appearances.
at_bats INTEGER
Official at-bats.
runs INTEGER
Runs scored.
hits INTEGER
Hits.
doubles INTEGER
Doubles.
triples INTEGER
Triples.
home_runs INTEGER
Home runs.
rbi INTEGER
Runs batted in.
stolen_bases INTEGER
Stolen bases.
caught_stealing INTEGER
Times caught stealing.
walks INTEGER
Bases on balls.
intentional_walks INTEGER
Intentional bases on balls.
strikeouts INTEGER
Strikeouts.
hit_by_pitch INTEGER
Times hit by a pitch.
sacrifice_bunts INTEGER
Sacrifice bunts.
sacrifice_flies INTEGER
Sacrifice flies.
total_bases INTEGER
Total bases.
grounded_into_double_play INTEGER
Grounded-into-double-play count.
pitches_seen INTEGER
Pitches seen.
left_on_base INTEGER
Runners left on base in the player's plate appearances.
batting_average DECIMAL(5,3)
Batting average as an exact decimal.
on_base_percentage DECIMAL(5,3)
On-base percentage as an exact decimal.
slugging_percentage DECIMAL(5,3)
Slugging percentage as an exact decimal.
ops DECIMAL(5,3)
On-base plus slugging as an exact decimal.
babip DECIMAL(5,3)
Batting average on balls in play.
ConstraintsPRIMARY KEY (player_id)
Example

Current MLB home-run leaders.

SELECT player_name, last_team_abbreviation, home_runs, ops
FROM mlb.main.current_batting
ORDER BY home_runs DESC
LIMIT 20;
Link
current_fielding 1 example37 cols

Current-season fielding statistics at player-position grain

Columns
season INTEGER
MLB season year.
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason.
player_idnot null INTEGER
Stable MLB player identifier.
player_name VARCHAR
Player's full name.
age INTEGER
Player age reported for this statistical season.
birth_date DATE
Player birth date.
primary_number VARCHAR
Uniform number, when available.
position_codenot null VARCHAR
MLB position code.
position_name VARCHAR
Position name.
position_abbreviation VARCHAR
Position abbreviation.
bats VARCHAR
Batting side code: L, R, or S.
throws VARCHAR
Throwing-hand code: L or R.
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals.
team_name VARCHAR
Team represented by this row; NULL for multi-team totals.
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals.
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals.
last_team_name VARCHAR
Last or current team MLB associates with the player.
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team.
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL.
league_name VARCHAR
League name.
league_abbreviation VARCHAR
League abbreviation, AL or NL.
num_teams INTEGER
Number of teams represented by this aggregate split.
num_leagues INTEGER
Number of leagues represented by this aggregate split.
games_played INTEGER
Games in which the player appeared at this position.
games_started INTEGER
Games started at this position.
innings VARCHAR
Fielding innings in baseball notation; .1 and .2 represent outs.
outs INTEGER
Fielding outs derived from MLB's innings notation.
putouts INTEGER
Putouts credited to the fielder.
assists INTEGER
Assists credited to the fielder.
errors INTEGER
Errors charged to the fielder.
throwing_errors INTEGER
Throwing errors charged to the fielder.
chances INTEGER
Total fielding chances.
double_plays INTEGER
Double plays involving the fielder.
triple_plays INTEGER
Triple plays involving the fielder.
fielding_percentage DECIMAL(5,3)
Successful chances divided by total chances.
range_factor_per_game DECIMAL(7,2)
Putouts plus assists per game at the position.
range_factor_per_nine DECIMAL(7,2)
Putouts plus assists per nine defensive innings.
ConstraintsPRIMARY KEY (player_id, position_code)
Example

Current shortstops with substantial defensive playing time.

SELECT player_name, last_team_abbreviation, outs, errors,
  fielding_percentage
FROM mlb.main.current_fielding
WHERE position_abbreviation = 'SS' AND outs >= 600
ORDER BY fielding_percentage DESC;
Link
current_pitching 1 example65 cols

Current-season pitching statistics, one row per MLB player

Columns
season INTEGER
MLB season year.
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason.
player_idnot null INTEGER
Stable MLB player identifier.
player_name VARCHAR
Player's full name.
age INTEGER
Player age reported for this statistical season.
birth_date DATE
Player birth date.
primary_number VARCHAR
Uniform number, when available.
position_code VARCHAR
MLB position code.
position_name VARCHAR
Position name.
position_abbreviation VARCHAR
Position abbreviation.
bats VARCHAR
Batting side code: L, R, or S.
throws VARCHAR
Throwing-hand code: L or R.
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals.
team_name VARCHAR
Team represented by this row; NULL for multi-team totals.
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals.
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals.
last_team_name VARCHAR
Last or current team MLB associates with the player.
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team.
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL.
league_name VARCHAR
League name.
league_abbreviation VARCHAR
League abbreviation, AL or NL.
num_teams INTEGER
Number of teams represented by this aggregate split.
num_leagues INTEGER
Number of leagues represented by this aggregate split.
games_played INTEGER
Games played.
games_pitched INTEGER
Games pitched.
games_started INTEGER
Games started.
games_finished INTEGER
Games finished.
wins INTEGER
Pitching wins.
losses INTEGER
Pitching losses.
saves INTEGER
Saves.
save_opportunities INTEGER
Save opportunities.
holds INTEGER
Holds.
blown_saves INTEGER
Blown saves.
complete_games INTEGER
Complete games.
shutouts INTEGER
Shutouts.
innings_pitched VARCHAR
Baseball innings notation from MLB; .1 and .2 mean one and two outs, not decimal fractions.
outs INTEGER
Outs recorded; use this for exact innings arithmetic.
batters_faced INTEGER
Batters faced.
hits INTEGER
Hits allowed.
runs INTEGER
Runs allowed.
earned_runs INTEGER
Earned runs allowed.
home_runs INTEGER
Home runs allowed.
walks INTEGER
Bases on balls allowed.
intentional_walks INTEGER
Intentional walks allowed.
strikeouts INTEGER
Strikeouts.
hit_batters INTEGER
Batters hit by a pitch.
wild_pitches INTEGER
Wild pitches.
balks INTEGER
Balks.
pickoffs INTEGER
Pickoffs.
pitches INTEGER
Pitches thrown.
strikes INTEGER
Strikes thrown.
era DECIMAL(7,2)
Earned run average.
whip DECIMAL(7,2)
Walks plus hits per inning pitched.
opponent_average DECIMAL(5,3)
Opposing batting average.
opponent_obp DECIMAL(5,3)
Opposing on-base percentage.
opponent_slg DECIMAL(5,3)
Opposing slugging percentage.
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging.
strike_percentage DECIMAL(5,3)
Share of pitches recorded as strikes.
win_percentage DECIMAL(5,3)
Pitching win percentage.
strikeout_walk_ratio DECIMAL(7,2)
Strikeouts divided by walks.
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings.
walks_per_nine DECIMAL(7,2)
Walks per nine innings.
hits_per_nine DECIMAL(7,2)
Hits per nine innings.
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings.
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings.
ConstraintsPRIMARY KEY (player_id)
Example

Current ERA leaders among pitchers with at least 300 outs.

SELECT player_name, last_team_abbreviation, innings_pitched, strikeouts, era
FROM mlb.main.current_pitching
WHERE outs >= 300
ORDER BY era
LIMIT 20;
Link
current_standings 2 examples45 cols

Current AL and NL regular-season standings, one row per team

Columns
season INTEGER
MLB season year.
standings_type VARCHAR
Requested standings view, such as regularSeason.
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL.
league_name VARCHAR
League name.
league_abbreviation VARCHAR
League abbreviation, AL or NL.
division_id INTEGER
MLB division identifier.
division_name VARCHAR
Division name.
division_abbreviation VARCHAR
Division abbreviation.
team_idnot null INTEGER
Stable MLB team identifier.
team_name VARCHAR
Full team name.
team_abbreviation VARCHAR
Team abbreviation.
division_rank INTEGER
Rank within the team's division.
league_rank INTEGER
Rank within the team's league.
sport_rank INTEGER
Rank across Major League Baseball.
wild_card_rank INTEGER
Wild-card rank when supplied by this standings view.
games_played INTEGER
Games played.
wins INTEGER
Wins.
losses INTEGER
Losses.
ties INTEGER
Ties, normally zero in regular-season MLB.
winning_percentage DECIMAL(4,3)
Winning percentage as an exact decimal.
games_back DECIMAL(6,1)
Division games back; a leader's '-' marker maps to 0.0.
games_back_display VARCHAR
MLB's original games-back display value.
wild_card_games_back DECIMAL(6,1)
Wild-card games back; '-' maps to 0.0.
wild_card_games_back_display VARCHAR
Original wild-card games-back value.
runs_scored INTEGER
Runs scored.
runs_allowed INTEGER
Runs allowed.
run_differential INTEGER
Runs scored minus runs allowed.
streak_code VARCHAR
Compact streak label, for example W3 or L1.
streak_type VARCHAR
Streak direction, wins or losses.
streak_number INTEGER
Length of the current streak.
home_wins INTEGER
Wins at home.
home_losses INTEGER
Losses at home.
away_wins INTEGER
Wins away.
away_losses INTEGER
Losses away.
last_ten_wins INTEGER
Wins in the team's last ten games.
last_ten_losses INTEGER
Losses in the team's last ten games.
division_leader BOOLEAN
Whether the team currently leads its division.
division_champ BOOLEAN
Whether the team has clinched its division.
has_wildcard BOOLEAN
Whether the team holds a wild-card place.
clinched BOOLEAN
Whether the team has clinched a postseason place.
clinch_indicator VARCHAR
MLB clinching marker, when present.
elimination_number VARCHAR
MLB's division/playoff elimination marker.
wild_card_elimination_number VARCHAR
MLB's wild-card elimination marker.
magic_number VARCHAR
MLB's displayed magic number.
last_updated TIMESTAMP WITH TIME ZONE
Time MLB last updated this team's record.
ConstraintsPRIMARY KEY (team_id)
Examples (2)

Current division tables in official rank order.

SELECT division_name, division_rank, team_name, wins, losses, games_back
FROM mlb.main.current_standings
ORDER BY division_name, division_rank;
Result · first 5 rows
division_name division_rank team_name wins losses games_back
American League Central 1 Cleveland Guardians 85 77 0
American League Central 2 Chicago White Sox 84 78 1
American League Central 3 Minnesota Twins 77 85 8
American League Central 4 Detroit Tigers 76 86 9
American League Central 5 Kansas City Royals 69 93 16

Teams with the best run differential.

SELECT team_name, wins, losses, run_differential
FROM mlb.main.current_standings
ORDER BY run_differential DESC;
Link
Table functions
advanced_batting_stats (game_type := VARCHAR, league := VARCHAR, qualified_only := BOOLEAN, season := INTEGER) 1 example

Advanced MLB batting statistics by season, league, and game type

Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
qualified_only := BOOLEAN
Return only players who qualify for the official rate-stat leaderboards. · default false
season := INTEGER
Season year. NULL asks MLB for its current season. · default null
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
plate_appearances INTEGER
Plate appearances represented by the row
total_bases INTEGER
Bases produced by hits
extra_base_hits INTEGER
Doubles, triples, and home runs combined
balls_in_play INTEGER
Batted balls put into play
total_swings INTEGER
Recorded swings
swing_and_misses INTEGER
Swings that missed the pitch
walk_offs INTEGER
Walk-off hits
reached_on_error INTEGER
Times reaching base on an error
gidp INTEGER
Grounded-into-double-play count
gidp_opportunities INTEGER
Grounded-into-double-play opportunities
babip DECIMAL(5,3)
Batting average on balls in play
isolated_power DECIMAL(5,3)
Slugging percentage minus batting average
pitches_per_plate_appearance DECIMAL(5,3)
Pitches seen per plate appearance
walks_per_plate_appearance DECIMAL(5,3)
Walks divided by plate appearances
strikeouts_per_plate_appearance DECIMAL(5,3)
Strikeouts divided by plate appearances
home_runs_per_plate_appearance DECIMAL(5,3)
Home runs divided by plate appearances
walks_per_strikeout DECIMAL(5,3)
Walks divided by strikeouts
Example

Qualified 2025 isolated-power leaders.

SELECT player_name, plate_appearances, isolated_power,
  strikeouts_per_plate_appearance
FROM mlb.main.advanced_batting_stats(season := 2025, qualified_only := true)
ORDER BY isolated_power DESC
LIMIT 20;
Link
advanced_pitching_stats (game_type := VARCHAR, league := VARCHAR, qualified_only := BOOLEAN, season := INTEGER) 1 example

Advanced MLB pitching statistics by season, league, and game type

Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
qualified_only := BOOLEAN
Return only players who qualify for the official rate-stat leaderboards. · default false
season := INTEGER
Season year. NULL asks MLB for its current season. · default null
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
batters_faced INTEGER
Batters faced
quality_starts INTEGER
Starts with at least six innings and at most three earned runs
inherited_runners INTEGER
Runners inherited on entry
inherited_runners_scored INTEGER
Inherited runners who scored
bequeathed_runners INTEGER
Runners left on base when the pitcher exited
bequeathed_runners_scored INTEGER
Bequeathed runners who later scored
balls_in_play INTEGER
Batted balls put into play against the pitcher
total_swings INTEGER
Recorded opposing swings
swing_and_misses INTEGER
Opposing swings that missed
babip DECIMAL(5,3)
Opposing batting average on balls in play
opponent_obp DECIMAL(5,3)
Opposing on-base percentage
opponent_slg DECIMAL(5,3)
Opposing slugging percentage
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging
isolated_power DECIMAL(5,3)
Opposing isolated power
strike_percentage DECIMAL(5,3)
Strikes divided by total pitches
whiff_percentage DECIMAL(5,3)
Swinging misses divided by swings
strikeouts_minus_walks_percentage DECIMAL(5,3)
Strikeout rate minus walk rate
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings
walks_per_nine DECIMAL(7,2)
Walks per nine innings
hits_per_nine DECIMAL(7,2)
Hits per nine innings
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings
pitches_per_inning DECIMAL(7,2)
Pitches per inning
pitches_per_plate_appearance DECIMAL(5,3)
Pitches per batter faced
Example

Qualified 2025 pitchers by K-minus-BB percentage.

SELECT player_name, strikeouts_minus_walks_percentage, whiff_percentage
FROM mlb.main.advanced_pitching_stats(season := 2025, qualified_only := true)
ORDER BY strikeouts_minus_walks_percentage DESC
LIMIT 20;
Link
all_current_batting () 1 example

Current MLB batting lines (scan behind current_batting)

No arguments
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
plate_appearances INTEGER
Plate appearances
at_bats INTEGER
Official at-bats
runs INTEGER
Runs scored
hits INTEGER
Hits
doubles INTEGER
Doubles
triples INTEGER
Triples
home_runs INTEGER
Home runs
rbi INTEGER
Runs batted in
stolen_bases INTEGER
Stolen bases
caught_stealing INTEGER
Times caught stealing
walks INTEGER
Bases on balls
intentional_walks INTEGER
Intentional bases on balls
strikeouts INTEGER
Strikeouts
hit_by_pitch INTEGER
Times hit by a pitch
sacrifice_bunts INTEGER
Sacrifice bunts
sacrifice_flies INTEGER
Sacrifice flies
total_bases INTEGER
Total bases
grounded_into_double_play INTEGER
Grounded-into-double-play count
pitches_seen INTEGER
Pitches seen
left_on_base INTEGER
Runners left on base in the player's plate appearances
batting_average DECIMAL(5,3)
Batting average as an exact decimal
on_base_percentage DECIMAL(5,3)
On-base percentage as an exact decimal
slugging_percentage DECIMAL(5,3)
Slugging percentage as an exact decimal
ops DECIMAL(5,3)
On-base plus slugging as an exact decimal
babip DECIMAL(5,3)
Batting average on balls in play
Example

Current home-run leaders from the backing scan.

SELECT player_name, home_runs
FROM mlb.main.all_current_batting()
ORDER BY home_runs DESC
LIMIT 10;
Link
all_current_fielding () 1 example

Current MLB fielding lines (scan behind current_fielding)

No arguments
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games in which the player appeared at this position
games_started INTEGER
Games started at this position
innings VARCHAR
Fielding innings in baseball notation; .1 and .2 represent outs
outs INTEGER
Fielding outs derived from MLB's innings notation
putouts INTEGER
Putouts credited to the fielder
assists INTEGER
Assists credited to the fielder
errors INTEGER
Errors charged to the fielder
throwing_errors INTEGER
Throwing errors charged to the fielder
chances INTEGER
Total fielding chances
double_plays INTEGER
Double plays involving the fielder
triple_plays INTEGER
Triple plays involving the fielder
fielding_percentage DECIMAL(5,3)
Successful chances divided by total chances
range_factor_per_game DECIMAL(7,2)
Putouts plus assists per game at the position
range_factor_per_nine DECIMAL(7,2)
Putouts plus assists per nine defensive innings
Example

Current shortstop fielding lines from the backing scan.

SELECT player_name, outs, errors
FROM mlb.main.all_current_fielding()
WHERE position_abbreviation = 'SS'
ORDER BY outs DESC
LIMIT 10;
Link
all_current_pitching () 1 example

Current MLB pitching lines (scan behind current_pitching)

No arguments
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
games_pitched INTEGER
Games pitched
games_started INTEGER
Games started
games_finished INTEGER
Games finished
wins INTEGER
Pitching wins
losses INTEGER
Pitching losses
saves INTEGER
Saves
save_opportunities INTEGER
Save opportunities
holds INTEGER
Holds
blown_saves INTEGER
Blown saves
complete_games INTEGER
Complete games
shutouts INTEGER
Shutouts
innings_pitched VARCHAR
Baseball innings notation from MLB; .1 and .2 mean one and two outs, not decimal fractions
outs INTEGER
Outs recorded; use this for exact innings arithmetic
batters_faced INTEGER
Batters faced
hits INTEGER
Hits allowed
runs INTEGER
Runs allowed
earned_runs INTEGER
Earned runs allowed
home_runs INTEGER
Home runs allowed
walks INTEGER
Bases on balls allowed
intentional_walks INTEGER
Intentional walks allowed
strikeouts INTEGER
Strikeouts
hit_batters INTEGER
Batters hit by a pitch
wild_pitches INTEGER
Wild pitches
balks INTEGER
Balks
pickoffs INTEGER
Pickoffs
pitches INTEGER
Pitches thrown
strikes INTEGER
Strikes thrown
era DECIMAL(7,2)
Earned run average
whip DECIMAL(7,2)
Walks plus hits per inning pitched
opponent_average DECIMAL(5,3)
Opposing batting average
opponent_obp DECIMAL(5,3)
Opposing on-base percentage
opponent_slg DECIMAL(5,3)
Opposing slugging percentage
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging
strike_percentage DECIMAL(5,3)
Share of pitches recorded as strikes
win_percentage DECIMAL(5,3)
Pitching win percentage
strikeout_walk_ratio DECIMAL(7,2)
Strikeouts divided by walks
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings
walks_per_nine DECIMAL(7,2)
Walks per nine innings
hits_per_nine DECIMAL(7,2)
Hits per nine innings
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings
Example

Current strikeout leaders from the backing scan.

SELECT player_name, strikeouts
FROM mlb.main.all_current_pitching()
ORDER BY strikeouts DESC
LIMIT 10;
Link
all_current_standings () 1 example

Current MLB regular-season standings (scan behind current_standings)

No arguments
Returns columns
season INTEGER
MLB season year
standings_type VARCHAR
Requested standings view, such as regularSeason
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
division_id INTEGER
MLB division identifier
division_name VARCHAR
Division name
division_abbreviation VARCHAR
Division abbreviation
team_id INTEGER
Stable MLB team identifier
team_name VARCHAR
Full team name
team_abbreviation VARCHAR
Team abbreviation
division_rank INTEGER
Rank within the team's division
league_rank INTEGER
Rank within the team's league
sport_rank INTEGER
Rank across Major League Baseball
wild_card_rank INTEGER
Wild-card rank when supplied by this standings view
games_played INTEGER
Games played
wins INTEGER
Wins
losses INTEGER
Losses
ties INTEGER
Ties, normally zero in regular-season MLB
winning_percentage DECIMAL(4,3)
Winning percentage as an exact decimal
games_back DECIMAL(6,1)
Division games back; a leader's '-' marker maps to 0.0
games_back_display VARCHAR
MLB's original games-back display value
wild_card_games_back DECIMAL(6,1)
Wild-card games back; '-' maps to 0.0
wild_card_games_back_display VARCHAR
Original wild-card games-back value
runs_scored INTEGER
Runs scored
runs_allowed INTEGER
Runs allowed
run_differential INTEGER
Runs scored minus runs allowed
streak_code VARCHAR
Compact streak label, for example W3 or L1
streak_type VARCHAR
Streak direction, wins or losses
streak_number INTEGER
Length of the current streak
home_wins INTEGER
Wins at home
home_losses INTEGER
Losses at home
away_wins INTEGER
Wins away
away_losses INTEGER
Losses away
last_ten_wins INTEGER
Wins in the team's last ten games
last_ten_losses INTEGER
Losses in the team's last ten games
division_leader BOOLEAN
Whether the team currently leads its division
division_champ BOOLEAN
Whether the team has clinched its division
has_wildcard BOOLEAN
Whether the team holds a wild-card place
clinched BOOLEAN
Whether the team has clinched a postseason place
clinch_indicator VARCHAR
MLB clinching marker, when present
elimination_number VARCHAR
MLB's division/playoff elimination marker
wild_card_elimination_number VARCHAR
MLB's wild-card elimination marker
magic_number VARCHAR
MLB's displayed magic number
last_updated TIMESTAMP WITH TIME ZONE
Time MLB last updated this team's record
Example

Read the table's backing scan directly.

SELECT division_name, team_name, wins, losses
FROM mlb.main.all_current_standings()
WHERE division_rank = 1
ORDER BY division_name;
Link
batting_career (player_id INTEGER, game_type := VARCHAR) 1 example

Career batting totals for one MLB player

Positional arguments
player_id INTEGER
Stable MLB player identifier.
Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
plate_appearances INTEGER
Plate appearances
at_bats INTEGER
Official at-bats
runs INTEGER
Runs scored
hits INTEGER
Hits
doubles INTEGER
Doubles
triples INTEGER
Triples
home_runs INTEGER
Home runs
rbi INTEGER
Runs batted in
stolen_bases INTEGER
Stolen bases
caught_stealing INTEGER
Times caught stealing
walks INTEGER
Bases on balls
intentional_walks INTEGER
Intentional bases on balls
strikeouts INTEGER
Strikeouts
hit_by_pitch INTEGER
Times hit by a pitch
sacrifice_bunts INTEGER
Sacrifice bunts
sacrifice_flies INTEGER
Sacrifice flies
total_bases INTEGER
Total bases
grounded_into_double_play INTEGER
Grounded-into-double-play count
pitches_seen INTEGER
Pitches seen
left_on_base INTEGER
Runners left on base in the player's plate appearances
batting_average DECIMAL(5,3)
Batting average as an exact decimal
on_base_percentage DECIMAL(5,3)
On-base percentage as an exact decimal
slugging_percentage DECIMAL(5,3)
Slugging percentage as an exact decimal
ops DECIMAL(5,3)
On-base plus slugging as an exact decimal
babip DECIMAL(5,3)
Batting average on balls in play
Example

Shohei Ohtani's regular-season career batting totals.

SELECT player_name, games_played, hits, home_runs, batting_average, ops
FROM mlb.main.batting_career(660271);
Link
batting_game_log (player_id INTEGER, end_date := DATE, game_type := VARCHAR, season := INTEGER, start_date := DATE) 2 examples

Per-game batting lines for one MLB player

Positional arguments
player_id INTEGER
Stable MLB player identifier.
Named arguments
end_date := DATE
Optional inclusive upper bound. · default null
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
season := INTEGER
Season year; NULL selects the current season. · default null
start_date := DATE
Optional inclusive lower bound. · default null
Returns columns
season INTEGER
MLB season year
game_pk INTEGER
Stable MLB game identifier
game_date DATE
Date of the game
game_type VARCHAR
MLB game-type code
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
team_id INTEGER
Team represented by this game line
team_name VARCHAR
Team represented by this game line
team_abbreviation VARCHAR
Team abbreviation for this game
opponent_id INTEGER
Opponent's MLB team identifier
opponent_name VARCHAR
Opponent's team name
opponent_abbreviation VARCHAR
Opponent's team abbreviation
is_home BOOLEAN
Whether the player's team was at home
is_win BOOLEAN
Whether the player's team won
summary VARCHAR
MLB's compact summary of the player's game line
plate_appearances INTEGER
Plate appearances in the game
at_bats INTEGER
Official at-bats in the game
runs INTEGER
Runs scored in the game
hits INTEGER
Hits in the game
doubles INTEGER
Doubles in the game
triples INTEGER
Triples in the game
home_runs INTEGER
Home runs in the game
rbi INTEGER
Runs batted in during the game
walks INTEGER
Walks in the game
strikeouts INTEGER
Strikeouts in the game
stolen_bases INTEGER
Stolen bases in the game
batting_average DECIMAL(5,3)
Batting average for the game line
on_base_percentage DECIMAL(5,3)
On-base percentage for the game line
slugging_percentage DECIMAL(5,3)
Slugging percentage for the game line
ops DECIMAL(5,3)
On-base plus slugging for the game line
Examples (2)

Shohei Ohtani's June 2025 batting game log.

SELECT game_date, opponent_abbreviation, summary
FROM mlb.main.batting_game_log(660271, season := 2025, start_date := DATE '2025-06-01', end_date := DATE '2025-06-30')
ORDER BY game_date;

Shohei Ohtani's 2025 batting split by whether the opponent finished at .500 or better, joining his batting_game_log() to the final standings() on opponent_id.

SELECT s.winning_percentage >= 0.500 AS opponent_500_or_better,
  count(*) AS games, sum(g.at_bats) AS at_bats, sum(g.hits) AS hits,
  sum(g.home_runs) AS home_runs,
  round(sum(g.hits) / sum(g.at_bats), 3) AS batting_average
FROM mlb.main.batting_game_log(660271, season := 2025) g
JOIN mlb.main.standings(season := 2025) s ON s.team_id = g.opponent_id
GROUP BY ALL
ORDER BY opponent_500_or_better;
Link
batting_stats (game_type := VARCHAR, league := VARCHAR, qualified_only := BOOLEAN, season := INTEGER) 1 example

MLB player batting statistics by season and league

Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
qualified_only := BOOLEAN
Return only players who qualify for the official rate-stat leaderboards. · default false
season := INTEGER
Season year. NULL asks MLB for its current season. · default null
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
plate_appearances INTEGER
Plate appearances
at_bats INTEGER
Official at-bats
runs INTEGER
Runs scored
hits INTEGER
Hits
doubles INTEGER
Doubles
triples INTEGER
Triples
home_runs INTEGER
Home runs
rbi INTEGER
Runs batted in
stolen_bases INTEGER
Stolen bases
caught_stealing INTEGER
Times caught stealing
walks INTEGER
Bases on balls
intentional_walks INTEGER
Intentional bases on balls
strikeouts INTEGER
Strikeouts
hit_by_pitch INTEGER
Times hit by a pitch
sacrifice_bunts INTEGER
Sacrifice bunts
sacrifice_flies INTEGER
Sacrifice flies
total_bases INTEGER
Total bases
grounded_into_double_play INTEGER
Grounded-into-double-play count
pitches_seen INTEGER
Pitches seen
left_on_base INTEGER
Runners left on base in the player's plate appearances
batting_average DECIMAL(5,3)
Batting average as an exact decimal
on_base_percentage DECIMAL(5,3)
On-base percentage as an exact decimal
slugging_percentage DECIMAL(5,3)
Slugging percentage as an exact decimal
ops DECIMAL(5,3)
On-base plus slugging as an exact decimal
babip DECIMAL(5,3)
Batting average on balls in play
Example

Qualified 2025 MLB OPS leaders.

SELECT player_name, last_team_abbreviation, home_runs, ops
FROM mlb.main.batting_stats(season := 2025, qualified_only := true)
ORDER BY ops DESC
LIMIT 20;
Link
batting_team_splits (player_id INTEGER, season INTEGER, game_type := VARCHAR) 1 example

One MLB player's season batting totals split by team

Positional arguments
player_id INTEGER
Stable MLB player identifier.
season INTEGER
Season year to split by team.
Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
plate_appearances INTEGER
Plate appearances
at_bats INTEGER
Official at-bats
runs INTEGER
Runs scored
hits INTEGER
Hits
doubles INTEGER
Doubles
triples INTEGER
Triples
home_runs INTEGER
Home runs
rbi INTEGER
Runs batted in
stolen_bases INTEGER
Stolen bases
caught_stealing INTEGER
Times caught stealing
walks INTEGER
Bases on balls
intentional_walks INTEGER
Intentional bases on balls
strikeouts INTEGER
Strikeouts
hit_by_pitch INTEGER
Times hit by a pitch
sacrifice_bunts INTEGER
Sacrifice bunts
sacrifice_flies INTEGER
Sacrifice flies
total_bases INTEGER
Total bases
grounded_into_double_play INTEGER
Grounded-into-double-play count
pitches_seen INTEGER
Pitches seen
left_on_base INTEGER
Runners left on base in the player's plate appearances
batting_average DECIMAL(5,3)
Batting average as an exact decimal
on_base_percentage DECIMAL(5,3)
On-base percentage as an exact decimal
slugging_percentage DECIMAL(5,3)
Slugging percentage as an exact decimal
ops DECIMAL(5,3)
On-base plus slugging as an exact decimal
babip DECIMAL(5,3)
Batting average on balls in play
Example

Josh Naylor's 2025 batting totals separated by team.

SELECT team_name, games_played, hits, home_runs, ops
FROM mlb.main.batting_team_splits(647304, 2025)
ORDER BY team_name;
Link
fielding_stats (game_type := VARCHAR, league := VARCHAR, season := INTEGER) 2 examples

MLB player fielding statistics by season, league, and game type

Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
season := INTEGER
Season year; NULL selects MLB's current season. · default null
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games in which the player appeared at this position
games_started INTEGER
Games started at this position
innings VARCHAR
Fielding innings in baseball notation; .1 and .2 represent outs
outs INTEGER
Fielding outs derived from MLB's innings notation
putouts INTEGER
Putouts credited to the fielder
assists INTEGER
Assists credited to the fielder
errors INTEGER
Errors charged to the fielder
throwing_errors INTEGER
Throwing errors charged to the fielder
chances INTEGER
Total fielding chances
double_plays INTEGER
Double plays involving the fielder
triple_plays INTEGER
Triple plays involving the fielder
fielding_percentage DECIMAL(5,3)
Successful chances divided by total chances
range_factor_per_game DECIMAL(7,2)
Putouts plus assists per game at the position
range_factor_per_nine DECIMAL(7,2)
Putouts plus assists per nine defensive innings
Examples (2)

2025 shortstops with at least 900 defensive outs.

SELECT player_name, last_team_abbreviation, outs, errors,
  fielding_percentage
FROM mlb.main.fielding_stats(season := 2025)
WHERE position_abbreviation = 'SS' AND outs >= 900
ORDER BY fielding_percentage DESC;

2025 shortstops with at least 2,400 defensive outs (800 innings) at the position, ranked by OPS alongside their errors and fielding percentage there.

SELECT f.player_name, f.last_team_abbreviation, f.outs, f.errors,
  f.fielding_percentage, b.plate_appearances, b.ops
FROM mlb.main.fielding_stats(season := 2025) f
JOIN mlb.main.batting_stats(season := 2025) b USING (player_id)
WHERE f.position_abbreviation = 'SS' AND f.outs >= 2400
ORDER BY b.ops DESC, f.player_id
LIMIT 10;
Link
pitching_career (player_id INTEGER, game_type := VARCHAR) 1 example

Career pitching totals for one MLB player

Positional arguments
player_id INTEGER
Stable MLB player identifier.
Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
games_pitched INTEGER
Games pitched
games_started INTEGER
Games started
games_finished INTEGER
Games finished
wins INTEGER
Pitching wins
losses INTEGER
Pitching losses
saves INTEGER
Saves
save_opportunities INTEGER
Save opportunities
holds INTEGER
Holds
blown_saves INTEGER
Blown saves
complete_games INTEGER
Complete games
shutouts INTEGER
Shutouts
innings_pitched VARCHAR
Baseball innings notation from MLB; .1 and .2 mean one and two outs, not decimal fractions
outs INTEGER
Outs recorded; use this for exact innings arithmetic
batters_faced INTEGER
Batters faced
hits INTEGER
Hits allowed
runs INTEGER
Runs allowed
earned_runs INTEGER
Earned runs allowed
home_runs INTEGER
Home runs allowed
walks INTEGER
Bases on balls allowed
intentional_walks INTEGER
Intentional walks allowed
strikeouts INTEGER
Strikeouts
hit_batters INTEGER
Batters hit by a pitch
wild_pitches INTEGER
Wild pitches
balks INTEGER
Balks
pickoffs INTEGER
Pickoffs
pitches INTEGER
Pitches thrown
strikes INTEGER
Strikes thrown
era DECIMAL(7,2)
Earned run average
whip DECIMAL(7,2)
Walks plus hits per inning pitched
opponent_average DECIMAL(5,3)
Opposing batting average
opponent_obp DECIMAL(5,3)
Opposing on-base percentage
opponent_slg DECIMAL(5,3)
Opposing slugging percentage
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging
strike_percentage DECIMAL(5,3)
Share of pitches recorded as strikes
win_percentage DECIMAL(5,3)
Pitching win percentage
strikeout_walk_ratio DECIMAL(7,2)
Strikeouts divided by walks
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings
walks_per_nine DECIMAL(7,2)
Walks per nine innings
hits_per_nine DECIMAL(7,2)
Hits per nine innings
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings
Example

Shohei Ohtani's regular-season career pitching totals.

SELECT player_name, games_started, innings_pitched, strikeouts, era, whip
FROM mlb.main.pitching_career(660271);
Link
pitching_game_log (player_id INTEGER, end_date := DATE, game_type := VARCHAR, season := INTEGER, start_date := DATE) 1 example

Per-game pitching lines for one MLB player

Positional arguments
player_id INTEGER
Stable MLB player identifier.
Named arguments
end_date := DATE
Optional inclusive upper bound. · default null
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
season := INTEGER
Season year; NULL selects the current season. · default null
start_date := DATE
Optional inclusive lower bound. · default null
Returns columns
season INTEGER
MLB season year
game_pk INTEGER
Stable MLB game identifier
game_date DATE
Date of the game
game_type VARCHAR
MLB game-type code
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
team_id INTEGER
Team represented by this game line
team_name VARCHAR
Team represented by this game line
team_abbreviation VARCHAR
Team abbreviation for this game
opponent_id INTEGER
Opponent's MLB team identifier
opponent_name VARCHAR
Opponent's team name
opponent_abbreviation VARCHAR
Opponent's team abbreviation
is_home BOOLEAN
Whether the player's team was at home
is_win BOOLEAN
Whether the player's team won
summary VARCHAR
MLB's compact summary of the player's game line
games_started INTEGER
One when the player started this game, otherwise zero
innings_pitched VARCHAR
Innings in baseball notation; .1 and .2 represent outs
outs INTEGER
Outs recorded in the game
hits INTEGER
Hits allowed in the game
runs INTEGER
Runs allowed in the game
earned_runs INTEGER
Earned runs allowed in the game
home_runs INTEGER
Home runs allowed in the game
walks INTEGER
Walks allowed in the game
strikeouts INTEGER
Strikeouts in the game
pitches INTEGER
Pitches thrown in the game
strikes INTEGER
Strikes thrown in the game
era DECIMAL(7,2)
Earned run average reported after the game line
whip DECIMAL(7,2)
Walks plus hits per inning for the game line
Example

Shohei Ohtani's 2025 pitching game log.

SELECT game_date, opponent_abbreviation, innings_pitched, strikeouts,
  summary
FROM mlb.main.pitching_game_log(660271, season := 2025)
ORDER BY game_date;
Link
pitching_stats (game_type := VARCHAR, league := VARCHAR, qualified_only := BOOLEAN, season := INTEGER) 2 examples

MLB player pitching statistics by season and league

Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
qualified_only := BOOLEAN
Return only players who qualify for the official rate-stat leaderboards. · default false
season := INTEGER
Season year. NULL asks MLB for its current season. · default null
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
games_pitched INTEGER
Games pitched
games_started INTEGER
Games started
games_finished INTEGER
Games finished
wins INTEGER
Pitching wins
losses INTEGER
Pitching losses
saves INTEGER
Saves
save_opportunities INTEGER
Save opportunities
holds INTEGER
Holds
blown_saves INTEGER
Blown saves
complete_games INTEGER
Complete games
shutouts INTEGER
Shutouts
innings_pitched VARCHAR
Baseball innings notation from MLB; .1 and .2 mean one and two outs, not decimal fractions
outs INTEGER
Outs recorded; use this for exact innings arithmetic
batters_faced INTEGER
Batters faced
hits INTEGER
Hits allowed
runs INTEGER
Runs allowed
earned_runs INTEGER
Earned runs allowed
home_runs INTEGER
Home runs allowed
walks INTEGER
Bases on balls allowed
intentional_walks INTEGER
Intentional walks allowed
strikeouts INTEGER
Strikeouts
hit_batters INTEGER
Batters hit by a pitch
wild_pitches INTEGER
Wild pitches
balks INTEGER
Balks
pickoffs INTEGER
Pickoffs
pitches INTEGER
Pitches thrown
strikes INTEGER
Strikes thrown
era DECIMAL(7,2)
Earned run average
whip DECIMAL(7,2)
Walks plus hits per inning pitched
opponent_average DECIMAL(5,3)
Opposing batting average
opponent_obp DECIMAL(5,3)
Opposing on-base percentage
opponent_slg DECIMAL(5,3)
Opposing slugging percentage
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging
strike_percentage DECIMAL(5,3)
Share of pitches recorded as strikes
win_percentage DECIMAL(5,3)
Pitching win percentage
strikeout_walk_ratio DECIMAL(7,2)
Strikeouts divided by walks
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings
walks_per_nine DECIMAL(7,2)
Walks per nine innings
hits_per_nine DECIMAL(7,2)
Hits per nine innings
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings
Examples (2)

Qualified 2025 pitchers ordered by ERA.

SELECT player_name, last_team_abbreviation, innings_pitched, strikeouts, era
FROM mlb.main.pitching_stats(season := 2025, qualified_only := true)
ORDER BY era
LIMIT 20;

2025 hitters with at least 50 plate appearances who also pitched, joining batting_stats() to pitching_stats() on player_id; mostly position players in mop-up relief, led by two-way Shohei Ohtani.

SELECT b.player_name, b.position_abbreviation, b.plate_appearances, b.ops,
  p.games_pitched, p.innings_pitched, p.era
FROM mlb.main.batting_stats(season := 2025) b
JOIN mlb.main.pitching_stats(season := 2025) p USING (player_id)
WHERE b.plate_appearances >= 50
ORDER BY p.games_pitched DESC, b.player_name
LIMIT 20;
Link
pitching_team_splits (player_id INTEGER, season INTEGER, game_type := VARCHAR) 1 example

One MLB player's season pitching totals split by team

Positional arguments
player_id INTEGER
Stable MLB player identifier.
season INTEGER
Season year to split by team.
Named arguments
game_type := VARCHAR
R regular season, S spring training, P postseason, or a specific postseason round. · default "R"
Returns columns
season INTEGER
MLB season year
game_type VARCHAR
MLB game-type code, such as R for regular season or P for postseason
player_id INTEGER
Stable MLB player identifier
player_name VARCHAR
Player's full name
age INTEGER
Player age reported for this statistical season
birth_date DATE
Player birth date
primary_number VARCHAR
Uniform number, when available
position_code VARCHAR
MLB position code
position_name VARCHAR
Position name
position_abbreviation VARCHAR
Position abbreviation
bats VARCHAR
Batting side code: L, R, or S
throws VARCHAR
Throwing-hand code: L or R
team_id INTEGER
Team represented by every statistic in this row; NULL for multi-team totals
team_name VARCHAR
Team represented by this row; NULL for multi-team totals
team_abbreviation VARCHAR
Abbreviation of the represented team; NULL for multi-team totals
last_team_id INTEGER
Last or current team MLB associates with the player, even for multi-team totals
last_team_name VARCHAR
Last or current team MLB associates with the player
last_team_abbreviation VARCHAR
Abbreviation of the player's last or current team
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
num_teams INTEGER
Number of teams represented by this aggregate split
num_leagues INTEGER
Number of leagues represented by this aggregate split
games_played INTEGER
Games played
games_pitched INTEGER
Games pitched
games_started INTEGER
Games started
games_finished INTEGER
Games finished
wins INTEGER
Pitching wins
losses INTEGER
Pitching losses
saves INTEGER
Saves
save_opportunities INTEGER
Save opportunities
holds INTEGER
Holds
blown_saves INTEGER
Blown saves
complete_games INTEGER
Complete games
shutouts INTEGER
Shutouts
innings_pitched VARCHAR
Baseball innings notation from MLB; .1 and .2 mean one and two outs, not decimal fractions
outs INTEGER
Outs recorded; use this for exact innings arithmetic
batters_faced INTEGER
Batters faced
hits INTEGER
Hits allowed
runs INTEGER
Runs allowed
earned_runs INTEGER
Earned runs allowed
home_runs INTEGER
Home runs allowed
walks INTEGER
Bases on balls allowed
intentional_walks INTEGER
Intentional walks allowed
strikeouts INTEGER
Strikeouts
hit_batters INTEGER
Batters hit by a pitch
wild_pitches INTEGER
Wild pitches
balks INTEGER
Balks
pickoffs INTEGER
Pickoffs
pitches INTEGER
Pitches thrown
strikes INTEGER
Strikes thrown
era DECIMAL(7,2)
Earned run average
whip DECIMAL(7,2)
Walks plus hits per inning pitched
opponent_average DECIMAL(5,3)
Opposing batting average
opponent_obp DECIMAL(5,3)
Opposing on-base percentage
opponent_slg DECIMAL(5,3)
Opposing slugging percentage
opponent_ops DECIMAL(5,3)
Opposing on-base plus slugging
strike_percentage DECIMAL(5,3)
Share of pitches recorded as strikes
win_percentage DECIMAL(5,3)
Pitching win percentage
strikeout_walk_ratio DECIMAL(7,2)
Strikeouts divided by walks
strikeouts_per_nine DECIMAL(7,2)
Strikeouts per nine innings
walks_per_nine DECIMAL(7,2)
Walks per nine innings
hits_per_nine DECIMAL(7,2)
Hits per nine innings
home_runs_per_nine DECIMAL(7,2)
Home runs per nine innings
runs_per_nine DECIMAL(7,2)
Runs allowed per nine innings
Example

Jhoan Duran's 2025 pitching totals separated by team.

SELECT team_name, games_pitched, innings_pitched, strikeouts, era
FROM mlb.main.pitching_team_splits(661395, 2025)
ORDER BY team_name;
Link
standings (league := VARCHAR, season := INTEGER, standings_type := VARCHAR) 3 examples

MLB standings by season, league, and standings view

Named arguments
league := VARCHAR
MLB for both leagues, AL for American League, or NL for National League. · default "MLB"
season := INTEGER
Season year. NULL asks MLB for its current season. · default null
standings_type := VARCHAR
MLB standings view to request. · default "regularSeason"
Returns columns
season INTEGER
MLB season year
standings_type VARCHAR
Requested standings view, such as regularSeason
league_id INTEGER
MLB league identifier: 103 for AL or 104 for NL
league_name VARCHAR
League name
league_abbreviation VARCHAR
League abbreviation, AL or NL
division_id INTEGER
MLB division identifier
division_name VARCHAR
Division name
division_abbreviation VARCHAR
Division abbreviation
team_id INTEGER
Stable MLB team identifier
team_name VARCHAR
Full team name
team_abbreviation VARCHAR
Team abbreviation
division_rank INTEGER
Rank within the team's division
league_rank INTEGER
Rank within the team's league
sport_rank INTEGER
Rank across Major League Baseball
wild_card_rank INTEGER
Wild-card rank when supplied by this standings view
games_played INTEGER
Games played
wins INTEGER
Wins
losses INTEGER
Losses
ties INTEGER
Ties, normally zero in regular-season MLB
winning_percentage DECIMAL(4,3)
Winning percentage as an exact decimal
games_back DECIMAL(6,1)
Division games back; a leader's '-' marker maps to 0.0
games_back_display VARCHAR
MLB's original games-back display value
wild_card_games_back DECIMAL(6,1)
Wild-card games back; '-' maps to 0.0
wild_card_games_back_display VARCHAR
Original wild-card games-back value
runs_scored INTEGER
Runs scored
runs_allowed INTEGER
Runs allowed
run_differential INTEGER
Runs scored minus runs allowed
streak_code VARCHAR
Compact streak label, for example W3 or L1
streak_type VARCHAR
Streak direction, wins or losses
streak_number INTEGER
Length of the current streak
home_wins INTEGER
Wins at home
home_losses INTEGER
Losses at home
away_wins INTEGER
Wins away
away_losses INTEGER
Losses away
last_ten_wins INTEGER
Wins in the team's last ten games
last_ten_losses INTEGER
Losses in the team's last ten games
division_leader BOOLEAN
Whether the team currently leads its division
division_champ BOOLEAN
Whether the team has clinched its division
has_wildcard BOOLEAN
Whether the team holds a wild-card place
clinched BOOLEAN
Whether the team has clinched a postseason place
clinch_indicator VARCHAR
MLB clinching marker, when present
elimination_number VARCHAR
MLB's division/playoff elimination marker
wild_card_elimination_number VARCHAR
MLB's wild-card elimination marker
magic_number VARCHAR
MLB's displayed magic number
last_updated TIMESTAMP WITH TIME ZONE
Time MLB last updated this team's record
Examples (3)

The 2025 final division standings.

SELECT division_name, division_rank, team_name, wins, losses
FROM mlb.main.standings(season := 2025)
ORDER BY division_name, division_rank;

The current American League wild-card race.

SELECT wild_card_rank, team_name, wild_card_games_back
FROM mlb.main.standings(league := 'AL', standings_type := 'wildCard')
ORDER BY wild_card_rank;

Each 2025 division winner's lowest-ERA qualified pitcher, joining standings() to pitching_stats() on team_id (pitchers traded mid-season have no team_id and are excluded).

SELECT s.division_name, s.team_name, s.wins, p.player_name,
  p.innings_pitched, p.strikeouts, p.era
FROM mlb.main.standings(season := 2025) s
JOIN mlb.main.pitching_stats(season := 2025, qualified_only := true) p ON p.team_id = s.team_id
WHERE s.division_rank = 1
QUALIFY row_number() OVER (PARTITION BY s.team_id ORDER BY p.era, p.player_id) = 1
ORDER BY s.division_name;
Link

Try these queries

current_standings_are_populated — MLB regular-season standings contain team rows.

SELECT count(*) > 0 AS populated FROM mlb.main.current_standings;

Uses current_standings

current_batting_has_players — The complete current batting pool has stable player identifiers.

SELECT count(*) > 0 AND count(player_id) = count(*) AS populated
FROM mlb.main.current_batting;

Uses current_batting

baseball_innings_are_exact — Every displayed pitching inning count agrees with the exact outs count.

SELECT bool_and(outs >= 0) AS valid_outs
FROM mlb.main.current_pitching
WHERE innings_pitched IS NOT NULL;

Uses current_pitching

Each 2025 division winner's lowest-ERA qualified pitcher, joining standings() to pitching_stats() on team_id (pitchers traded mid-season have no team_id and are excluded).

SELECT s.division_name, s.team_name, s.wins, p.player_name,
  p.innings_pitched, p.strikeouts, p.era
FROM mlb.main.standings(season := 2025) s
JOIN mlb.main.pitching_stats(season := 2025, qualified_only := true) p ON p.team_id = s.team_id
WHERE s.division_rank = 1
QUALIFY row_number() OVER (PARTITION BY s.team_id ORDER BY p.era, p.player_id) = 1
ORDER BY s.division_name

Uses standingspitching_stats

2025 hitters with at least 50 plate appearances who also pitched, joining batting_stats() to pitching_stats() on player_id; mostly position players in mop-up relief, led by two-way Shohei Ohtani.

SELECT b.player_name, b.position_abbreviation, b.plate_appearances, b.ops,
  p.games_pitched, p.innings_pitched, p.era
FROM mlb.main.batting_stats(season := 2025) b
JOIN mlb.main.pitching_stats(season := 2025) p USING (player_id)
WHERE b.plate_appearances >= 50
ORDER BY p.games_pitched DESC, b.player_name
LIMIT 20

Uses batting_statspitching_stats

2025 shortstops with at least 2,400 defensive outs (800 innings) at the position, ranked by OPS alongside their errors and fielding percentage there.

SELECT f.player_name, f.last_team_abbreviation, f.outs, f.errors,
  f.fielding_percentage, b.plate_appearances, b.ops
FROM mlb.main.fielding_stats(season := 2025) f
JOIN mlb.main.batting_stats(season := 2025) b USING (player_id)
WHERE f.position_abbreviation = 'SS' AND f.outs >= 2400
ORDER BY b.ops DESC, f.player_id
LIMIT 10

Uses fielding_statsbatting_stats

22 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Show the current MLB division leaders and how many games back each second-place team is.
  • Who were the top ten qualified MLB hitters by OPS in 2025?
  • Break Jhoan Duran's 2025 pitching results out by team; his MLB player ID is 661395.
  • List Shohei Ohtani's June 2025 batting game log; his MLB player ID is 660271.
  • Who currently leads MLB in home runs, and who currently leads in strikeouts?
  • Return the final 2025 MLB division standings in division-rank order.

MLB is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.