Answer the question
In order to leave comments, you need to log in
Laravel, multiple aggregates in one column?
Hello! There is a table with a color(string) field, how to get the number of each color in one query?
The result is like this:
red 20
green 45
black 23
Answer the question
In order to leave comments, you need to log in
Dig mentioned in the comments
https://laravel.com/docs/8.x/queries#grouping
And pay attention to this:
->selectRaw('count(id) as number_of_orders, customer_id')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question