Skip to content
On this page


Prisma client allows you to aggregate on the int fields (such as Int and Float) of your models. The following query returns the average age of all users:

final age = prisma.user.aggregate().$avg().age();

print('Average age: $age');

You can combine aggregation with filtering and ordering. For example, the following query returns the average age of users:

  • Ordered by age ascending
  • Where email contains
  • Limited to the 10 users
final agregate = prisma.user.aggregate(
  where: UserWhereInput(
    email: StringFilter( contains: '' ),
  orderBy: [
    UserOrderByWithRelationInput(age: OrderByArg.asc)
  take: 10,

final age = await agregate.$avg().age();

print('Average age: $age');


  • $avg() - Returns the average Fluent API
  • $count() - Returns the count Fluent API
  • $max() - Returns the maximum Fluent API
  • $min() - Returns the minimum Fluent API
  • $sum() - Returns the sum Fluent API

Released under the BSD-3-Clause License