Query Library

Casey Trauer submitted this query on: July 21, 2009 11:46am EDT
TITLE Count games played at one position
SPORTS Baseball
QUERY SELECT count(*)

FROM person_event_metadata pem
JOIN events e ON e.id = pem.event_id
JOIN events_sub_seasons ess ON ess.event_id = e.id
JOIN sub_seasons ss ON ess.sub_season_id = ss.id
JOIN positions pos ON pem.position_id = pos.id
JOIN persons p ON p.id = pem.person_id
JOIN publishers pub ON e.publisher_id = pub.id

WHERE ss.sub_season_key = '2009_season_regular'
AND p.person_key = 'l.mlb.com-p.5381' /*Player key here*/
AND pos.abbreviation = '1' /*Position abbreviation here*/
AND pem.status IS NOT NULL /*Filter out players who never made it into the game*/ 
AND pub.publisher_key = 'sportsnetwork.com';
DESCRIPTION Returns # of games played at one position for boxscores from TSN. All the season boxscores should be processed for this query to work correctly.
DBs TESTED MySQL
ADDITIONAL NOTES You can narrow down games STARTED at one position by changing the pem.status clause to: pem.status = 'starter'.
Your log.directory config setting does not point to a writable directory.