Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - average compute the average of expressions in work area http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 average             Compute the average of expressions in work area
------------------------------------------------------------------------------
 Syntax
   [!sAlias] average exps to vars [scope] [while lExp] [for lExp]

 Arguments
   sAlias is a database alias to operate on.
   exps is a list of numeric expressions.
   vars is a list of variables that receive the results of calculations.
   scope specifies a portion of the source database.
   lExp is a logical expression.

 Description
   The average command totals the values of all expressions in the exps
   list for every record in the current or selected alias, then divides the
   result by the number of records within scope and assigns the result
   to the corresponding variable in the vars list.

   The default scope of average is all. Every variable defined in vars
   must be dbl type and may not be a field variable.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   proc Test_average
   vardef
      dbl nBalance
   enddef
   open sTest
   average sTest->balance to nBalance
   ? "Average balance of customers is", nBalance
   endproc

   proc main
   Test_average()
   endproc

See Also: Database command scope table count sum

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson