Laravel groupBy with select multiple field

  eloquent, laravel, laravel-query-builder

I can select country and groupBy the result as following with an alias total :

Data::select('country', DB::raw('count(*) as total'))
->groupBy('country')
->get();

The above code works well.
Here I can select only country filed, But I need to select aslo name, positions field, How can I select multiple field here?

Source: Laravel

Leave a Reply