简体   繁体   English

Laravel Eloquent ORM GroupBy() 并返回

[英]Laravel Eloquent ORM GroupBy() and also return

I have a table room_details.我有一张桌子 room_details。 Now, I am simply identifying month wise data which is grouped by location and count office_location_id, How can I write MySql query for this?现在,我只是识别按位置和计数 office_location_id 分组的月份数据,我该如何为此编写 MySql 查询?

Here is that I want这是我想要的

Month------Location------office_location_id January----location 1 --- 11 February---location 3 --- 25 March------location 4 --- 40月-----位置------office_location_id 一月----位置 1 --- 2 月 11 日---位置 3 --- 3 月 25 日-----位置 4 --- 40

Here is my table, enter image description here这是我的桌子,请在此处输入图片描述

I don't know where month and location data are, but you can write your query like the example that I write below:我不知道月份和位置数据在哪里,但是您可以像我在下面写的示例一样编写查询:

SELECT month,location,COUNT(office_location_id)
FROM table_name
GROUP BY month;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM