Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3   11.4    Statistic    FMM    Blog  

FM.SQL.Sum

Calculates sum value in a record set.

Component Version macOS Windows Linux Server iOS SDK
FM FMSQL 9.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "FM.SQL.Sum"; SQLref; Column { ; firstRow; lastRow } )   More

Parameters

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

Result

Returns number or error.

Description

Calculates sum 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.

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

Release notes

Blog Entries

Created 30th January 2019, last changed 26th February 2021


FM.SQL.RowCount - FM.SQL.Text

Feedback: Report problem or ask question.




Links
MBS FileMaker tutorial videos

Start Chat