Skip to content

Miscellaneous

minimum()

minimum() — returns any

Calculates the minimum value for a given property. Uses the SQL function MIN. If no records can be found to perform the calculation on you can use the ifNull argument to decide what should be returned.

NameTypeRequiredDefaultDescription
propertystringyesName of the property to get the lowest value for (must be a property of a numeric data type).
wherestringyesSee documentation for findAll.
includestringyesSee documentation for findAll.
parameterizeanyyestrueSee documentation for findAll.
ifNullanyyesSee documentation for average.
includeSoftDeletesbooleanyesfalseSee documentation for findAll.
groupstringyesSee documentation for findAll.
// Get the amount of the lowest salary for all employees
lowestSalary = model("employee").minimum("salary");

// Get the amount of the lowest salary for employees in a given department
lowestSalary = model("employee").minimum(property="salary", where="departmentId=##params.key##");

// Make sure a numeric amount is always returned, even when there were no records analyzed by the query
lowestSalary = model("employee").minimum(property="salary", where="salary BETWEEN ##params.min## AND ##params.max##", ifNull=0);