Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Calculates average value in a record set.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL | 9.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
SQLref | The reference number returned by FM.SQL.Execute function. | $SQLRef | |
Column | The index of the column. Default is 0. |
0 | |
firstRow | The index of first row. Default is 0. |
0 | Optional |
lastRow | The index of last row. Default is FM.SQL.RowCount-1. |
5 | Optional |
Returns number or error.
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 ]
This function checks for a license.
Created 30th January 2019, last changed 26th February 2021