Home > Enterprise >  Group By dengan Count & Order By in laravel
Group By dengan Count & Order By in laravel

Time:08-17

please help SELECT CUSTOMER, COUNT(USER_ID) FROM ticket_table GROUP BY CUSTOMER ORDER BY COUNT(USER_ID) DESC LIMIT 10; for the following query when implemented in the Laravel query builder, what kind of controller is it?

CodePudding user response:

Do you mean like this :

\DB::table('ticket_table')
->selectRaw('customer, count(user_id)')
->groupBy('customer')
->orderBy(\DB::raw('COUNT(user_id)'), 'DESC')
->limit(10);
  • Related