Results 1 to 7 of 7
  1. #1
    graympa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    4

    Max value based on criteria in three different tables

    Brand new to Access; am trying to learn by doing. I am interested as much in learning the best methods as I am the actual answer.



    I am trying to display the starting quarterback for teams in the NFL, based on pass attempts. I have a table of teams, of players, and of performance (week and pass attempts). What I want to do is show, for each team and week, who threw the most passes that week. I think I should group the quarterbacks by team, and then figure who had the most passes for each week in that group. Do I do this all at once (how?), or create a query (to get team / QBs) and then query from that?

    Thanks.

  2. #2
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    So do you have 1 table with those data elements or 3 tables?

    The data structure you're using will tell how to build the queries you want.

  3. #3
    graympa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    4
    Sorry wasn't clearer. 3 tables: Teams (Team_Name), Players(Position,Team), and Stats(Player_ID,Pass_Attempts).

  4. #4
    graympa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    4
    Stats also has Week.

  5. #5
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Seems like you could do it all at once. Add all relevant tables to query, group by team, then on the total line do MAX for number of passes. only put team, quarterback and numpasses as your fields to see if its working right. Then you can add other fields if you need to.

  6. #6
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    I'm going to make some assumptions here.

    Team
    TeamID
    TeamName

    Players
    PlayerID
    PlayerName
    PlayerPosition
    TeamID

    Stats
    StatsID
    PlayerID
    Gamedate
    PassesAttempted
    PassesCompleted

    Your Query would then look like this

    Select Team.TeamName, Player.PlayerName, stats.gamedate, stats.PassesAttempted
    From Stats Inner join Player on stats.PlayerID = Player.PlayerID Inner Join Team on Player.TeamID = Team.TeamID
    Where GameDate between [Startdate] and [enddate]
    Order By stats.gamedate, stats.PassesAttempted desc

    With the data structure I provided you could also query on most PassesCompleted by week or Highest Completion Percentage by week.

  7. #7
    graympa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    4
    Okay, that worked. My problem was I didn't set up my relationships correctly, and I didn't do the inner joins correctly . I realized I can do it design view and then go back and see how SQL does it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-25-2013, 08:49 AM
  2. Query for table, based on criteria from other tables
    By PureLoneWolf in forum Queries
    Replies: 2
    Last Post: 10-04-2012, 11:23 AM
  3. Criteria based on value in another field
    By karusya in forum Access
    Replies: 1
    Last Post: 04-03-2012, 01:46 PM
  4. Matching based on criteria from multiple tables
    By Jonpro03 in forum Database Design
    Replies: 13
    Last Post: 08-04-2011, 10:29 AM
  5. Replies: 1
    Last Post: 06-12-2011, 07:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums