Results 1 to 3 of 3

Thread: SQL Error, Please help

  1. #1
    Join Date
    Jun 2003
    Location
    NC
    Posts
    11

    SQL Error, Please help

    Hi, I'm trying to grab this info from my table using the SELECT statement: teamid, wins, losses, tie, pf, pa

    Here's my statement:
    SELECT teamid, Sum (wins), Sum (losses), Sum (tie), Sum (pf), Sum (pa) FROM team_stats WHERE conf='AFC'

    Here's the error I am getting:
    [Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'teamid' as part of an aggregate function.

    The only thing I can think of is "teamid" is set as a primary key in Access. I'm just wondering if I have it written out correctly, or if there is a better way to pull that info from the table.

    Thanks,

    David

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Since all other columns have aggregate (SUM), you must use group by on teamid

    SELECT teamid, Sum (wins), Sum (losses), Sum (tie), Sum (pf), Sum (pa) FROM team_stats WHERE conf='AFC'
    group by teamid

  3. #3
    Join Date
    Jun 2003
    Location
    NC
    Posts
    11
    Ahh..thanks so much. That worked out great. This site is really a great source.

    Thank you,

    David

Posting Permissions

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