Is there a way to query for a record that with the...
# prisma-whats-new
d
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
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
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.