Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / September 2005

Tip: Looking for answers? Try searching our database.

Averages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 26 Sep 2005 21:50 GMT
I need to create a query that will give me averages on a list of numbers.

How can I calculate the averages, but ignore 0 or null values. Addtionally
if I am ignoreing the 0 value I don't want the record field to factored in
the average count.

e.g.

5
0
2
4

In this senario I would want the averages to be be caluated on the 3 records
with values in excess of 0., 5+2+4=11  11/3 =3.6

If I took the 0 value I would end up with an average of 11/4=2.75

Any help would be appreciated.
Rick B - 26 Sep 2005 21:59 GMT
One post per question, please.

Signature

Rick B

> I need to create a query that will give me averages on a list of numbers.
>
[quoted text clipped - 15 lines]
>
> Any help would be appreciated.
S.Clark [Access MVP] - 26 Sep 2005 22:01 GMT
You could do two queries.  One to exclude what you don't want in the calc,
then the second to perform the calc.

Steve Clark, Access MVP
FMS, Inc

> I need to create a query that will give me averages on a list of numbers.
>
[quoted text clipped - 15 lines]
>
> Any help would be appreciated.
John Spencer (MVP) - 26 Sep 2005 23:35 GMT
MyAverage: Avg(IIF(TheField=0,Null,TheField))

> I need to create a query that will give me averages on a list of numbers.
>
[quoted text clipped - 15 lines]
>
> Any help would be appreciated.
Jeff Boyce - 27 Sep 2005 00:59 GMT
Robert

Are all your values in the same field, multiple rows, or are you trying to
average like you might a spreadsheet (multiple columns of numbers in the
same row)?

Regards

Jeff Boyce
<Access MVP>

>I need to create a query that will give me averages on a list of numbers.
>
[quoted text clipped - 16 lines]
>
> Any help would be appreciated.
Michel Walsh - 27 Sep 2005 11:23 GMT
Hi,

SELECT AVG(fieldName)
FROM tableName
WHERE fieldName <> 0

will return 3.6. The WHERE clause is applied before the aggregations
occurred. If you need a criteria to be applied AFTER the aggregation
occurred, you use a HAVING clause. Most aggregate also remove the NULL
(unknown) values from consideration.

Hoping it may help,
Vanderghast, Access MVP

>I need to create a query that will give me averages on a list of numbers.
>
[quoted text clipped - 16 lines]
>
> Any help would be appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.