Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

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

This function checks for a license.

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


FM.SQL.RowCount - FM.SQL.Text