1、count 統計數量,參數是要統計的字段名(可選填)
//靜態調用 User::count(); User::where('status','>',0)->count(); //動態調用 $user = new User; $user->count(); $user->where('status','>',0)->count();
2、max 獲取最大值,參數是要統計的字段名(必填)
//靜態調用 User::max('score'); User::where('status','>',0)->max('score'); //動態調用 $user = new User; $user->max('score'); $user->where('status','>',0)->max('score');
3、min 獲取最小值,參數是要統計的字段名(必填)
//靜態調用 User::min('score'); User::where('status','>',0)->min('score'); //動態調用 $user = new User; $user->min('score'); $user->where('status','>',0)->min('score');
4、avg 獲取平均值,參數是要統計的字段名(必填)
//靜態調用 User::avg('score'); User::where('status','>',0)->avg('score'); //動態調用 $user = new User; $user->avg('score'); $user->where('status','>',0)->avg('score');
5、sum 獲取總分,參數是要統計的字段名(必填)
//靜態調用 User::sum('score'); User::where('status','>',0)->sum('score'); //動態調用 $user = new User; $user->sum('score'); $user->where('status','>',0)->sum('score');
