聚合查询

统计(COUNT)

  1. $num = User::where(['type' => 1])->count()

求和(SUM)

  1. User::where(['type' => 1])->sum('balance')

平均值

  1. User::where(['type' => 1])->avg('balance')

最大值

  1. User::where(['type' => 1])->max('balance')

最小值

  1. User::where(['type' => 1])->min('balance')