Dan Waters
df.waters at comcast.net
Tue Jul 12 14:39:25 CDT 2011
This is the complete paragraph: ------------------ FIRST versus GROUP BY SELECT EmployeeID, LastName, Notes FROM Employees GROUP BY EmployeeID, LastName, Notes; SELECT EmployeeID, First(LastName) AS FirstOfLastName, First(Notes) AS FirstOfNotes FROM Employees GROUP BY EmployeeID; When you add a field to a Totals query, Access offers Group By in the Total row. The default behavior, therefore, is that Access must group on all these fields. A primary key is unique. So, if you group by the primary key field, there is no need to group by other fields in that table. You can optimize the query by choosing First instead of Group By in the Total row under the other fields. First allows JET to return the value from the first matching record, without needing to group by the field. This makes a major difference with Memo fields. If you GROUP BY a memo (Notes in the example), Access compares only the first 255 characters, and the rest are truncated! By choosing First instead of Group By, JET is free to return the entire memo field from the first match. So not only is it more efficient; it actually solves the the problem of memo fields being chopped off. (A downside of using First is that the fields are aliased, e.g. FirstOfNotes.) ------------------