Advertisement
rodro1

count post by month, year query mysql

Sep 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.29 KB | None | 0 0
  1. SELECT
  2. year(created_at) as year,
  3. monthname(created_at) as month, //// month=1 // monthname=january, february
  4. count(*) published
  5. FROM posts
  6. GROUP BY year, month
  7.  
  8. on laravel
  9. ==
  10. App\Post::selectRaw('year(created_at) as year, monthname(created_at) as month')->groupBy('year', 'month')->get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement