本文介绍了如何在Laravel查询构建器中按创建日期计算行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按created_at来计算行数
I am trying to count the rows by created_at like
Created_at COUNT(*) ----------------------------------- ---------- 2017-08-13 5 2017-08-12 6 2017-08-11 7 2017-07-10 8 2017-07-19 1
所以我可以向客户展示2017年10月10日这样的项目,有8位用户注册.在2017-08-13年,有5位用户注册或类似的内容.这是我尝试过的,
So i can show the client like in 2017-07-10 , there are 8 people sign up.In 2017-08-13 ,there are 5 people sign up or something like that. Here is my tried,
$count=DB::table('jobseekers')->select('created_at')->groupBy('created_at')->count(); // return $count; dd($count);但这只是显示数字.谢谢您,谢谢.
But this is just showing only the number.Please guide me,thanks in advanced.
推荐答案您可以尝试以下方法:
$count = DB::table('jobseekers') ->select('created_at', DB::raw('count(*) as peoples')) ->groupBy('created_at') ->get();更多推荐
如何在Laravel查询构建器中按创建日期计算行数?
发布评论