Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to use Aggregate methods in Laravel 5

mysql laravel
How to use Aggregate methods in Laravel 5

The query builder also provides a variety of aggregate methods such as count, max, min, avg, and sum. You may call any of these methods after constructing your query.

Aggregate method is a method 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.

Count method

$count = DB::table('tbl_add_post')->count();

Min method

$amount = DB::table('tbl_orders')->min('amount');

Max method

$amount = DB::table('tbl_orders')->max('amount');

Sum method

$amount = DB::table('tbl_orders')->sum('amount');

Avg method

$amount = DB::table('tbl_orders')
                ->where('status', 1)


Html code work in comment box

Related Post