尝试按小时分组记录时发生错误

时间:2018-10-23 11:49:05

标签: laravel

我正在laravel上开发一个项目,我需要按搜索到的小时数对记录进行分组,但是没有运气,直到现在这是我想到的代码,它显示了一个错误 这是代码:

$buyers = buyer::groupBy(DB::raw('HOUR(created_at)'))->get();

这是错误:

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'larates.buyers.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select * from `buyers` group by HOUR(created_at))

有什么想法吗?

0 个答案:

没有答案