Share via

SQL issue in a query - Error 3122

Anonymous
2020-07-27T19:13:51+00:00

Hello! Please help me out with the following below SQL: 

The error I get says: "Your query does not include the specified expression 'Order' as part of an aggregate function." Would you please tell me what exactly I am missing on/after FROM? Thank you. Daler

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2020-07-27T20:00:29+00:00

    I will carry on with sweating over it. If a solution pans out, I will let you know. Thank you.

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2020-07-27T19:43:13+00:00

    We can't answer that without knowing what the fields are. In a Group By query, you have to Group By the field(s) that cover the aggregate function. For example. if you have an extended price for each line item in an Order, and you want to sum the extended price for all line items in the order, then you would do something like this:

    SELECT OrderID, Sum(ExtendedPrice) AS TotalPrice

    FROM OrderDetails

    Group By OrderID;

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. HansV 462.6K Reputation points
    2020-07-27T19:23:27+00:00

    The part

    Sum([Dst_Congressional]+[Dst_

     appears to be incomplete: the closing square bracket ] and closing parenthesis ) are missing.

    Apart from that, a query involving Sum(...) is a totals query. Any column not using Sum, Count, Avg or similar must be listed in the GROUP BY clause, but your query doesn't have one.

    Was this answer helpful?

    0 comments No comments
  5. ScottGem 68,830 Reputation points Volunteer Moderator
    2020-07-27T19:21:16+00:00

    Hi Daler, I'm an independent adviser and will try to help.

    There are two issues I see. First, the word Order is a keyword in Access and shouldn't be used as an object name. Second, You are using aggregate functions (SUM()) but you aren't using a Group By. That is probably the main reason.

    Its not 100% clear what you are trying to do here. Also there seems to be a part of the SQL statement missing before the FROM clause.

    If you need further clarification on this feel free to ask. But it would help if you explained what you are trying to do with this query.

    Was this answer helpful?

    0 comments No comments