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 - sum total expressions for each record within a scope http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 sum                 Total expressions for each record within a scope
------------------------------------------------------------------------------
 Syntax
   [!sAlias] sum expressions to variables [scope] [while lExp] [for lExp]

 Arguments
   sAlias is the database to operate on.
   expressions is a comma-separated list of numeric expressions.
   variables is a comma-separated list of dbl variables.
   scope specifies a portion of the source database.
   lExp is a logical expression.

 Description
   The sum command totals expressions for each record within scope for the
   current or selected database, then assigns the result to variables.

   sum adds the value of all expressions in expressions for all records in an
   alias and assigns the result to the corresponding variable in variables.
   Variables defined in variables must be type dbl and may not be field
   variables.

   The default scope of the sum command is all.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   proc Test_sum
   vardef
      dbl   eTotal
      dbl   nDiscount
      ulong nAge
   enddef
   nDiscount := 0.12
   eTotal := 0
   open sTest
   sum sTest->balance to eTotal
   ? eTotal
   go 50
   !sTest sum rest sTest->balance * nDiscount to eTotal
   ? eTotal
   go top
   !sTest sum sTest->balance, sTest->age to eTotal, nAge
   ? eTotal, nAge
   endproc

   proc main
   Test_sum()
   endproc

See Also: Database command scope table average count

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