Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average Function Not Working Properly

Status
Not open for further replies.

djs45uk

Technical User
Nov 7, 2004
103
GB
Hi all

I'm using the following SQL statement to calculate the average results in a table.

Code:
SELECT Avg(results.resultsQ1) AS AvgOfresultsQ1 FROM results WHERE (((results.participantCourseID)=23);

The answer it gives is 3. But the table looks like this:

4,4,3,2,3,4,4,4,3,3

Now if my maths is correct, the answer should actually by 3.4.

Please does anyone know how to fix this problem as it is a really important part of my database -- I've got these average calculations everywhere.

Any help is very much appreciated

Many thanks

Daniel
 
Most likely your data types are integers or longs so Vb os "helping you out" by doing integer arithemetic. Try computing your average as
Code:
SELECT Avg([COLOR=blue]cDbl([/color]results.resultsQ1[COLOR=blue])[/color]) AS AvgOfresultsQ1 

FROM results 

WHERE (((results.participantCourseID)=23);
 
You haven't changed any property of AvgOfresultsQ1 ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top