How to count and do averages

  • Thread starter Thread starter Sharp
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top