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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

averaging in queries

Status
Not open for further replies.

mattsuppok

Instructor
Jan 28, 2003
14
US
I have three fields in a query and I want to add those three fields and create a column with the average of those totals. Some of the records will be null. What do I do? Simply creating an expression, "avg([field1]+[field2])" doesn't seem to work.. Please advise
 
Try
Code:
   ... Avg(Nz([Field1]) + Nz([Field2]) + Nz([Field3])) As AvgValue, ...
 
Don't know if that will work because when I try it I get the same error everytime I try "avg".. the error reads as "you have tried to execute a query that does not include the specified expression 'instrutorlname' as part of an aggregate funciton"... the field 'inst.." is just a field that is on the query. The error on shows when I use a function. I have even tried "sum" and have the same results.... more ideas? thanks
 
OK
If your query is something like this
Code:
Select instrutorlname, ... other fields ..., Avg(...)
Then you need a Group By clause for each field that is not part of the Aggregate function (Avg in this case).
Code:
   GROUP BY  instrutorlname, ... other fields ...
 
don't want to group by any field.. just want this..

eval1 eval2 eval3 average
2 2 2
3 3 4
3 4

all I want to do is display the average for those 3 fields.
 
OK ... then don't put any other fields in your SELECT statement. The message you're getting is saying that you are selecting fields (specifically instrutorlname) in addition to the field that contains the computed average.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top