Topics
All
Mac OS X
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Guides
Examples
New in version:
7.4
7.5
8.0
8.1
8.2
8.3
8.4
8.5
9.0
9.1
Statistic
FM.SQL.Avg
Calculates average value in a record set.
Component | Version | macOS | Windows | Server | FileMaker Cloud | FileMaker iOS SDK |
FM | 9.1 | Yes | Yes | Yes | Yes | Yes |
Parameters
Parameter | Description | Example value |
---|---|---|
SQLref | The reference number returned by FM.SQL.Execute function. | $SQLRef |
Column | The index of the column. Default is 0. |
0 |
firstRow | Optional The index of first row. Default is 0. |
0 |
lastRow | Optional The index of last row. Default is FM.SQL.RowCount-1. |
5 |
Result
Returns number or error.
Description
Calculates average value in a record set.You got a record set in memory and we can walk over a column in a given row range to add the sum value and later divide by number of values.
Examples
Query once and make several calculations:
# let FileMaker query data once
Set Variable [ $Records ; Value: MBS( "FM.SQL.Execute"; Get(FileName); "SELECT Price FROM Produkte") ]
# Now get sum, min, max and avg
Set Variable [ $sum ; Value: MBS( "FM.SQL.Sum"; $records; 0) ]
Set Variable [ $min ; Value: MBS( "FM.SQL.Min"; $records; 0) ]
Set Variable [ $max ; Value: MBS( "FM.SQL.Max"; $records; 0) ]
Set Variable [ $avg ; Value: MBS( "FM.SQL.Avg"; $records; 0) ]
Set Variable [ $text ; Value: MBS( "FM.SQL.Text"; $records; "" /* firstRow */; "" /* lastRow */; "" /* firstCol */; "" /* lastCol */; ", " /* rowSep */) ]
Set Variable [ $r ; Value: MBS( "FM.SQL.Release"; $records ) ]
Show Custom Dialog [ "Sum: " & $sum & ¶ & "Min: " & $min & ¶ & "Max: " & $max & ¶ & "Avg: " & $avg & ¶ & "text: " & $text ]
See also
- FM.SQL.Execute
- FM.SQL.Max
- FM.SQL.Min
- FM.SQL.Release
- FM.SQL.RowCount
- FM.SQL.Sum
- FM.SQL.Text
- SQL.Execute
Created 30th January 2019, last changed 30th January 2019
FM.RunScriptLater - FM.SQL.CSV
Feedback: Report problem or ask question.
Links
MBS FileMaker blog