Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 14222 Viewer | Category : Laravel
Share this post:
We mostly required to get sum of amount, salary etc in laravel. We can also get sum of column using mysql SUM(). We have two way to get sum of column value. first we can use laravel sum() of query builder and another one we can use with directly with select statement using DB::raw(). I give you both example you can see and use any one as perfect for you.
$data = DB::table("click")->sum('numberofclick');
$data = DB::table("click")
->select(DB::raw("SUM(numberofclick) as count"))
- Laravel 5 - generate PDF from html view file and download using dompdf
- Laravel 5 Instagram API tutorial with example
- Laravel 5 create custom artisan command with example
- Laravel 5 - Barcode generator example using milon/barcode package
- Laravel 5.3 - image dimension validation rules example
- Jquery - How to copy text to clipboard without flash example ?
- Mediafire PHP file uploading and get link example
- Angularjs Simple Datepicker directive example code with Demo