Laravel 5 select with sum query exampleBy Hardik Savani | June 8, 2016 | | 46150 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 integrate jQuery Fullcalendar using Bootstrap, PHP and MySQL ?
- How to connect mysql database in node js with example?
- Solved - Access Not Configured. Google+ API (truncated...) on google console developer
- Bootstrap progress bar animate example using bootstrap-progressbar.js
- Laravel after login, redirect back to previous url ?
- Solve - no connection could be made target machine actively refused it laravel
- How to redirect page using JQuery?
- How to create Pagination using dirPagination directive in Angularjs example with demo ?