Difference between revisions of "AVGVALUES()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to return the average value of a column for a matching series of keys
 
Function to return the average value of a column for a matching series of keys
 
  
 
==Syntax==
 
==Syntax==
 
AVGVALUES(<expN> [, <for condition> [, <key-expression>]])
 
AVGVALUES(<expN> [, <for condition> [, <key-expression>]])
 
  
 
==See Also==
 
==See Also==
[[AVERAGE]], [[COUNT]], [[AMAX()]], [[AMIN()]], [[CNTVALUES()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[SQLVALUES()]], [[SUM]], [[SUMVALUES()]], [[ALLVALUES()]]
+
[[ALLVALUES()]], [[AVERAGE]], [[COUNT]], [[AMAX()]], [[AMIN()]], [[CNTVALUES()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[SUM]], [[SUMVALUES()]], [[TOTAL]]
, [[TOTAL]]
+
  
 
==Description==
 
==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.
 
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==
 
==Example==
Line 29: Line 25:
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 +
[[Category:Data Analysis Functions]]
 +
[[Category:Lianja VFP Extensions]]
 +
[[Category:VFP Function Extensions]]
 +
[[Category:Lianja VFP Extensions]]
 +
[[Category:VFP Function Extensions]]

Latest revision as of 07:20, 10 December 2012

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

ALLVALUES(), AVERAGE, COUNT, AMAX(), AMIN(), CNTVALUES(), MAX(), MAXVALUES(), MIN(), MINVALUES(), 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())