2

I need to make a query from my table where I track page views and group the results by the time of the day, more specifically group them by 2 hour interval. Now I am getting results by each hour:

 $visitorTraffic = DB::table('views')
      ->select(DB::raw('MONTH(created_at) as m, YEAR(created_at) as y, HOUR(created_at) as h, count(*)'))
      ->groupBy(DB::raw('HOUR(created_at)'))
      ->get();
Ludwig
  • 1,401
  • 13
  • 62
  • 125
  • could this be helpful? http://stackoverflow.com/questions/10429611/mysql-group-by-hours – Claudio King May 09 '16 at 15:02
  • I found a code that works for each hour, it is the code that I have updated the question with, now I just need to make it work somehow for time intervals of 2 hours and not 1 hour. – Ludwig May 09 '16 at 15:07

0 Answers0