Group by year month example in Laravel 5 using Query BuilderBy Hardik Savani | June 20, 2016 | | 2938 Viewer | Category : Laravel
Share this post:
Sometimes, we have created_at column with timestamp and we wanted to get with group by with month, that way we can use for chart. However, you can do it using mysql MONTH() function. we can use DB raw with mysql function and get group by monthly records.
So, you can see bellow query and use it.
->select("id" ,DB::raw("(COUNT(*)) as total_click"))
- PHP: How to count files in folder?
- How to get last record of database table in Laravel?
- Laravel 5 create and download zip file example using chumper/zipper composer package
- Codeigniter 3 and AngularJS CRUD with Search and Pagination Example.
- PHP - File upload progress bar with percentage using form jquery example
- How to get last executed mysql query in laravel ?
- How to change app version code in Ionic framework
- Multiple database connections in laravel 5 Application