Laravel error: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT()

前端 未结 1 361
梦谈多话
梦谈多话 2021-01-22 07:56

Anyone familiar with this Laravel Error:

\"SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with

1条回答
  •  抹茶落季
    2021-01-22 08:56

    You have to use groupBy():

    $feedback_data = DB::table('feedback')
        ->select(DB::raw('office, avg(q1) as q1, avg(q2) as q2'))
        ->groupBy('office')
        ->get();
    

    0 讨论(0)
提交回复
热议问题