group by之后的按语句排序在cpanel中不起作用,但在localhost中起作用


Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column '' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select class, count(*) as total from students group by class order by id asc)


        $groups = DB::table('students')
            ->select('class', DB::raw('count(*) as total'))
            ->orderBy('id', 'ASC')

i want to arrange in assending order by class. in bar chart. but it give error in order by line but correctly runs in my localhost. can you please help me with the query. It was my expectation It was my expectation

but without ordering i get this one without ordering