我需要从我的表中进行查询,在该表中我跟踪页面查看并按一天的时间对结果进行分组,更具体地说,将它们按2小时间隔进行分组。现在我每小时都会收到结果:
$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();