Share via

MS Access GROUP BY problem

Anonymous
2011-10-24T14:53:01+00:00

Hi, I'm trying to execute this query:

SELECT YOUNGPERSON.IDNUMBER, YOUNGPERSON.SURNAME

FROM YOUNGPERSON

GROUP BY YOUNGPERSON.SURNAME;

but I get the following error from MS Access(2007) :

"You tried to execute a query that does not include the specified expression 'IDNUMBER' as part of an aggregate function".

 Microsoft's documentation implies that an aggregate function is not mandatory for the use of the GROUP BY clause. What;s up?!!

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

Answer accepted by question author

Anonymous
2011-10-24T16:10:24+00:00

You have to include all fields in the GROUP BY statement that do not have Avg, Count, Sum, Min, Max, etc.

What are you trying to accomplish?

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-10-25T11:07:25+00:00

    Thanks for your response. I can't achieve what I want using the group by. So I'll find another way!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-10-24T16:51:52+00:00

    You can get the same results without using GROUP BY

    SELECT DISTINCT YOUNGPERSON.IDNUMBER, YOUNGPERSON.SURNAME

    FROM YOUNGPERSON

    OR

    SELECT YOUNGPERSON.IDNUMBER, YOUNGPERSON.SURNAME

    FROM YOUNGPERSON

    GROUP BY YoungPerson.IdNumber, YOUNGPERSON.SURNAME

    Was this answer helpful?

    0 comments No comments