PDA

View Full Version : More Difficult Select Statement for Newbie


bytwo
06-30-03, 10:52 PM
as soon as I add the "Avg" function I get the error message below. If I remove the AVG I get just the first value from the first row. I'm trying
to retrieve the Top 3 records then average col1. Any help please?


SELECT DISTINCT TOP 3 Avg(col1) AS some_name, col2 FROM some_table WHERE col2 = '" & some_var & "' ORDER BY col2"


Microsoft JET Database Engine error '80040e21'

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

Shane
07-01-03, 12:14 AM
add the Group By col1 to the end of your query.

bytwo
07-01-03, 05:46 AM
What is that saying??? Keep it simple stupid.. Thank you very much. It worked. I must have been up to late.

Thanks again!