Odd averages result from query

dxp

Registered User.
Local time
Today, 04:59
Joined
Jun 5, 2006
Messages
62
I am trying to calculate the average patients age from 2671 records using this SQL:

SELECT tbl_Customer_Details.DOB, CalcAge([DOB]) AS Age, DAvg("[Age]","qryAvgAge") AS Average
FROM tbl_Customer_Details
GROUP BY tbl_Customer_Details.DOB, CalcAge([DOB]);

why am I getting the result:

68.1131066106

I would have thought that it would have been 68 a whole number, has anyone got any suggestions why this should be.

thanks
 
it sounds like you are getting the right answer

can you format [average] as an integer, if you dont want the dps
 
Like this:

SELECT tbl_Customer_Details.DOB, CalcAge([DOB]) AS Age, CInt(DAvg("[Age]","qryAvgAge")) AS Average
FROM tbl_Customer_Details
GROUP BY tbl_Customer_Details.DOB, CalcAge([DOB]);

You're getting decimals because that's what averages do, even if you're averaging integers.

68+68+68+69 = 273
Average = 273/4, which equals 68.25
 
thanks for that Gemma and Moniker, added the CInt bit to the SQL and got the whole number.

The importance of the calculation is so that I can target advertising to the right age group ie Saga magazine readers as opposed to trying a younger magazine. My database contains 12,000 records so far and it would have been impossible to work out the average age manualy, it will save me a lot of wasted money in dead advertising; hence the need for accuracy.

thanks again
 

Users who are viewing this thread

Back
Top Bottom