0 votes
in Laravel by
List some Aggregates methods provided by query builder in Laravel ?

1 Answer

0 votes
by

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()

$products = DB::table(‘products’)->count();

max()

    $price = DB::table(‘orders’)->max(‘price’);

min()

    $price = DB::table(‘orders’)->min(‘price’);

avg()

    *$price = DB::table(‘orders’)->avg(‘price’);

sum()

    $price = DB::table(‘orders’)->sum(‘price’);

Source: laravelinterviewquestions.com   

...