1
我想拉一群用户自指定日期以来没有进行交易。Laravel中的嵌套查询5.2查询生成器拉MAX日期
这是我的查询:
$notActive = DB::table('transactions')
->join('users','transaction.user_id', '=', 'users.user_id')
->select(DB::raw('users.user_id, users.name, max(transaction.last_posted_date) AS lastDate'))
->groupBy('users.user_id')
->where('lastDate', '<', ''.$not.'');
return Datatables::of($notActive)
->make(true);
$不能是日期值拉到这将产生一个Ajax数据表中的错误。我已经尝试了这种多种方式,包括在where子句中将最大日期的select语句放入,但不断抛出错误。有没有更好的方法来查询我想要的这些数据?谢谢。