如何在Laravel查询构建器中按创建日期计算行数?

编程入门 行业动态 更新时间:2024-10-25 14:31:34
本文介绍了如何在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查询构建器中按创建日期计算行数?

本文发布于:2023-10-28 23:15:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538049.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:创建日期   行数   器中   如何在   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!