在我的应用中,我想获取基于socket_it
和created_at
的驱动程序在线小时数。我怎样才能做到这一点?有人帮助我,谢谢。这是我的桌子
结果如下:
$query = DB::table('tms_time_logs');
$query->where('tms_time_logs.user_id', 170);
$query->where('tms_time_logs.type', 'driver');
$query->orderBy('tms_time_logs.id', 'DESC');
$query->groupBy(DB::raw('Date(tms_time_logs.created_at)'));
$query->groupBy('tms_time_logs.socket_id');
$query->select(DB::raw('count(*) as count, HOUR(created_at) as hour'));
$performances = $query->get();