Counting and Finding Max

Results 1 to 2 of 2

Thread: Counting and Finding Max

  1. #1
    Join Date
    Dec 1969

    Default Counting and Finding Max

    I have two tables in an Access Database:<BR><BR>Table: Divisions<BR>Field: DivisionID (Autonumber - Primary Key)<BR><BR>Table: Teams<BR>Field: TeamID (Autonumber - Primary Key)<BR>Field: DivisionID (Foriegn Key)<BR><BR>There are several teams belonging to each division. I want an SQL statement to find the maximum number of teams belonging to any one division. So if there were were 3 Divisions, one with 1 team, one with 2 teams, one with 5 teams, it would return 5. Can I have the syntax to retrieve this number? Thanks in advance :-)<BR><BR>

  2. #2 Guest

    Default RE: Counting and Finding Max

    Select top 1 DivisionId, Count(TeamID) from Teams group by DivisionID<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts