Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 2501 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"))
- Jquery select2 ajax autocomplete example with demo in PHP
- Laravel 5 json response from controller example
- How to get ckeditor value with tags on ajax-submit ?
- How to remove null values from array in PHP?
- How to create and check custom header with middleware for REST API in Laravel 5 ?
- PHP - File upload progress bar with percentage using form jquery example
- Laravel 5 dropbox api file upload example using league/flysystem-dropbox package
- How to solve 'There are no commands defined in the "cashier" namespace' in Laravel 5