聚合查询

统计(COUNT)

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

求和(SUM)

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

平均值

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

最大值

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

最小值

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