-
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
-
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
-
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
-
Forum Rules
|
|