AVGVALUES()
Purpose
Function to return the average value of a column for a matching series of keys
Syntax
AVGVALUES(<expN> [, <for condition> [, <key-expression>]])
See Also
AVERAGE, COUNT, AMAX(), AMIN(), CNTVALUES(), MAX(), MAXVALUES(), MIN(), MINVALUES(), SQLVALUES(), SUM, SUMVALUES(), ALLVALUES() , TOTAL
Description
The AVGVALUES() function returns the average value of <expN> for the matching series of keys. The required <expN> parameter must be a column name from a table. If none of the optional parameters is specified, then the average value for the number of keys matching the current key is returned. An optional <for condition> can be specified to restrict the rows included in the operation. You can also optionally specify a <key-expression> to be used instead of the current key. After completion, all record pointers and indexes are returned to the original position.
Example
use customer order title // Average the balance column for // the number of records matching the current key total_balance = avgvalues(balance) // Average the balance column for // the number of records matching the key "Mr" m_male = avgvalues(balance, .T., "Mr") // Average the balance column for the number of records matching // the current key with an expiry date < today m_expired = avgvalues(balance, expiry < date())
Products
Recital Server, Recital