Title
d

dardub

09/13/2017, 7:44 PM
Is there a way to query for a record that with the MAX value on an int field? Been searching but haven't found any leads.
d

dankent

09/14/2017, 11:44 AM
there's isn't a build in max aggregation but one approach you can use is to sort by the field in descending order and return only one result, using the orderBy and first arguments
d

dardub

09/15/2017, 5:14 PM
Thanks @dankent That's what I did, I was just concerned about the overhead in this technique. In SQL, you wouldn't want to do this for large record sets.
Though the other day I was thinking maybe just create a field that stores the max value and update that via a hook.