Avg Function not working in Access
Hi,
I want o remove average of two columns in Microsoft Access for that i have use avg() function.But when I am attempting to do this instead of average of two columns i am getting summed totals.I don't know what's my mistake can one tell me my mistake.
Re: Avg Function not working in Access
Avg is a group function in Access.This is not as same as average function which we had in other, it's totally based on group.So if the group contains only 1 instance.Then avg() will be the same value of the underlying field or expression.
Re: Avg Function not working in Access
In Access SQL function, Avg is based on rows not columns
for example if a table contains two fields
[Data1] and [Data2]
If the table has 2 rows
Row 1 [Data1]=3 [Data2]=4
Row 2 [Data1]=5 [Data2]=6
then fro removing average of this two columns in Access you need to write it as Avg([Data1]+[Data2])=[(3+4)+(5+6)]/2=9.
Over here i have divide it by 2 because there are 2 rows in this example.
Re: Avg Function not working in Access
You can also use the Avg function in the query design grid, in an SQL statement in SQL view of the Query window, or in an SQL statement within Visual Basic code.
For example
SELECT Position, Avg(Sal) AS AvgSal
FROM EmployeeStatisticsTable
GROUP BY Position