简体   繁体   中英

Laravel Eloquent ORM GroupBy() and also return

I have a table 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?

Here is that I want

Month------Location------office_location_id January----location 1 --- 11 February---location 3 --- 25 March------location 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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