Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 29973 Viewer | Category : Laravel
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 - Create modular structure application example using L5Modular package
- How to scrolling table with fixed header in HTML?
- How to add mysql trigger from migrations in Laravel 5?
- AngularJS - How to Limit String Length using Filter?
- Laravel 5 Autocomplete using Bootstrap Typeahead JS Example with Demo
- Laravel 5 - Image Upload and Resize Example using Intervention Image Package
- How to check user login or not in Laravel 5?
- How to set gmail configration for mail in Laravel?