Average a field in SQL?

Results 1 to 2 of 2

Thread: Average a field in SQL?

  1. #1
    Join Date
    Dec 1969

    Default Average a field in SQL?

    How can I average a field in SQL? And where would I see the output?

  2. #2
    Join Date
    Dec 1969

    Default SELECT Avg(fieldname)

    SELECT Avg(fieldname) AS whateverNameYouWant, ... other fields ...<BR>FROM table<BR>WHERE ... some condition optional ...<BR>GROUP BY field, field, field ...<BR><BR>It is important to note that the average (and any "aggregate" functions) operates on a *group* of records (which can be all the records in the recordset if no GROUP BY is given).<BR><BR>But note that GROUP BY has its *own* rules: The only fields you can SELECT when you use GROUP BY are those given *in* the GROUP BY along with any aggregates you might use.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts