List some Aggregates methods provided by query builder in Laravel ?
Aggregate function is a function where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning or measurements such as a set, a bag or a list
Below is list of some Aggregates methods provided by Laravel query builder.
- count()Usage:$products = DB::table(‘products’)->count();
- max()Usage:$price = DB::table(‘orders’)->max(‘price’);
- min()Usage:$price = DB::table(‘orders’)->min(‘price’);
- avg()Usage:$price = DB::table(‘orders’)->avg(‘price’);
- sum()Usage: $price = DB::table(‘orders’)->sum(‘price’);