Let's simplify what is really needed here. With VFP8, the SQL has been brought more in line with SQL used by DBs like SQL Server and Oracle. When a GROUP BY is used, the SQL engine expects EVERY field in the SELECT list in the GROUP BY list EXCEPT those that are aggregated with functions like SUM(), MAX() and MIN(). When you added the other fields from the SELECT list to the GROUP BY in your code, the error went away which is correct since none of your fields in the SELECT were aggregated. For example:
SELECT CustID, MAX(InvoiceAmount) FROM INVOICES
GROUP BY CustID
is correct. If you omitted the GROUP BY in the example, you would get 1 record with the maximum InvoiceAmount and a CustID, but you could not be assured the CustID represented the Customer with the highest InvoiceAmount.
When your SQL has no aggregate functions, any GROUP BY should include all fields in the SELECT list.
Mark McCasland
Midlothian, TX USA