Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 63202 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"))
- How to Uninstall a Package in Laravel 5 Using Composer Command?
- How to add custom jquery validation for image file upload in summernote ?
- How to remove current changes from local system in Git ?
- Ajax Image Upload Example with Validation in PHP Laravel Framework
- How to create Laravel Resource Controller example?
- How to get maximum key value of array in PHP?
- Laravel 5 Join with subquery in Query Builder Example
- How to add ckeditor with image upload in Laravel ?