How to count and do averages

S

Sharp

Hi

Consider the table:

tblExample
PrimaryKey_FieldOne FieldTwo
1223 120
2232 220
3233 450
4233 550
5233 660

How to count the number of rows that have data in FieldTwo greater than
average?
So, first i want to find the average of the data in FieldTwo,
then count the number of rows that have a FieldTwo greater than the
calculated average.

Tried:
SELECT *
FROM tblExample
WHERE COUNT(FieldTwo > AVERAGE(FieldTwo));

Any help appreciated.

Cheers
Michael
 
T

Tom Wickerath

I think this will work:

SELECT Count(*) AS NumRecordsGTAverage
FROM tblExample
WHERE (((tblExample.FieldTwo)>(SELECT Avg(tblExample.FieldTwo)
AS AvgOfFieldTwo FROM tblExample)));


Tom
__________________________________

Hi

Consider the table:

tblExample
PrimaryKey_FieldOne FieldTwo
1223 120
2232 220
3233 450
4233 550
5233 660

How to count the number of rows that have data in FieldTwo greater than
average?
So, first i want to find the average of the data in FieldTwo,
then count the number of rows that have a FieldTwo greater than the
calculated average.

Tried:
SELECT *
FROM tblExample
WHERE COUNT(FieldTwo > AVERAGE(FieldTwo));

Any help appreciated.

Cheers
Michael
 
Top