Back
maximum()
Calculates the maximum value for a given property.
Uses the SQL function MAX
.
If no records can be found to perform the calculation on you can use the ifNull
argument to decide what should be returned.
// Get the amount of the highest salary for all employees highestSalary = model("employee").maximum("salary"); // Get the amount of the highest salary for employees in a given department highestSalary = model("employee").maximum(property="salary", where="departmentId=#params.key#"); // Make sure a numeric value is always returned, even if no records are found to calculate the maximum for highestSalary = model("employee").maximum(property="salary", where="salary > #params.minSalary#", ifNull=0);
Copied!