|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Difficult Select Statement for a Newbie
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. |
|
#2
|
|||
|
|||
|
You can must group the non aggregrate column if you are attempting to retrieve more than on row.
SELECT avg(col1), col2 from some_table where col2 = something GROUP BY col2 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Difficult Select Statement for a Newbie |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|