Query Library

Casey Trauer submitted this query on: June 11, 2009 4:56pm EDT
TITLE AP poll query
SPORTS American Football, Basketball
QUERY SELECT dn.first_name, dn.last_name, rankings.ranking_type, rankings.ranking_value
FROM rankings
JOIN sub_seasons ss ON rankings.date_coverage_id = ss.id
JOIN seasons s ON ss.season_id = s.id
JOIN affiliations a ON s.league_id = a.id
JOIN teams t ON rankings.participant_id = t.id
JOIN display_names dn ON t.id = dn.entity_id
JOIN document_fixtures df ON rankings.document_fixture_id = df.id
WHERE ss.sub_season_key = '2008_season_regular'
AND df.fixture_key = 'poll-ap'
AND dn.entity_type = 'teams'
AND a.affiliation_key = 'l.ncaa.org.mfoot'
DESCRIPTION This returns several rows for each team. Each row contains a distinct value: rank, ranking-points and ranking-first-place-votes. You can narrow down the query to return just rank.
DBs TESTED MySQL
ADDITIONAL NOTES