Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 3359 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"))
- How to change Bootstrap Datepicker with specific date format?
- How to get current url with parameters in Laravel 5?
- Order by using multiple columns and manually array field in Laravel?
- Laravel 5 - Multiple Images Uploading using dropzone.js example with demo
- PHP - autocomplete websites with domain and logo using clearbit API
- Mysql procedure with pagination in laravel 5?
- Example of unionAll in Query Builder Laravel 5
- Laravel 5 - line chart example code using google charts API