Difference between revisions of "AVGVALUES()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(Class)
Line 1: Line 1:
==Class==
 
Fields and Records
 
  
  

Revision as of 17:07, 26 October 2009


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(), 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 Database Server, Recital Mirage Server, Recital Terminal Developer