Hosted on SourceForge
and licensed under
Creative Commons GNU GPL.
| Casey Trauer submitted this query on: July 10, 2009 10:26am EDT | |
| TITLE | Season offensive stats for all players on one MLB team |
|---|---|
| SPORTS | Baseball |
| QUERY | SELECT dn_player.first_name, dn_player.last_name, p.person_key, dn_team.full_name, t.team_key, off.* FROM stats s JOIN baseball_offensive_stats off ON s.stat_repository_id = off.id JOIN teams t ON s.stat_membership_id = t.id JOIN persons p ON s.stat_holder_id = p.id JOIN sub_seasons ss ON s.stat_coverage_id = ss.id JOIN display_names dn_player ON s.stat_holder_id = dn_player.entity_id JOIN display_names dn_team ON s.stat_membership_id = dn_team.entity_id WHERE s.stat_holder_type = 'persons' AND s.stat_coverage_type = 'sub_seasons' AND ss.sub_season_key = '2009_season_regular' AND s.stat_repository_type = 'baseball_offensive_stats' AND dn_player.entity_type = 'persons' AND dn_team.entity_type = 'teams' AND t.team_key = 'l.mlb.com-t.1'; |
| DESCRIPTION | Returns regular season offensive stats for all players on one MLB team. |
| DBs TESTED | MySQL |
| ADDITIONAL NOTES | This query returns every column in the baseball_offensive_stats table (off.*), but be aware that the source data may not populate every column, so you may see NULL values in some fields. |
"Adds in events_played to query. Shows show you can join the stats table twice to retrieve data from multiple stat tables for each player."