Level 63
Try this.
->groupBy('created_at')
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hi i got this error when trying to make a chart
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'klinik_bersalin.ibu.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
and this is my controller
public function index()
{
$ibu = Ibu::select(DB::raw("COUNT(*) as count"), DB::raw("MONTHNAME(created_at) as month_name"))
->whereYear('created_at', date('Y'))
->groupBy(DB::raw("Month(created_at)"))
->pluck('count', 'month_name');
$labels = $ibu->keys();
$data = $ibu->values();
return view('chart', compact('labels', 'data'));
}
How do i resolve it? Thank you
Try this.
->groupBy('created_at')
Please or to participate in this conversation.