GROUP BY Problems

Silv3rSurf3r_20
01-12-2004, 12:40 PM
Good Day,

I have a small problem here... i'm trying to create a report using the designer. I need to group some records by SeqNum and seem to be getting an error which i don't comprehend. Here's a fragment of the Query:

SQLQuery = "SELECT SeqNum, PatientID, Date, PaymentTerms, PaymentDescription, AddPaymentDesc, Amount " _
& " FROM Payment WHERE PatientID = '" & myId & "'GROUP BY SeqNum"

and this is the error i get:
"You tried to execute a query that does not include the specified expression 'PatientID' as part of an aggregate function."

What does this mean and what do i have to do for me to be able to successfully execute the SQL Query above.

Thank You

~John~

reboot
01-12-2004, 01:09 PM
Try using Order By instead of Group By

00100b
01-12-2004, 01:20 PM
GROUP BY is generally used to perform aggregate functions (like COUNT, SUM, AVG, etc). When using GROUP BY, you need to include each field in the SELECT statement that is not being used in an aggregate function.

SELECT Field1, Field2, SUM(Field3) FROM Table1 GROUP BY Field1, Field2

If you wish to just sort the results, then the ORDER BY clause (as reboot suggested) is what you want to use.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum