sql group by 不起作用,我想按 code_branch 分组

sql groupby doesnt work, I want to be grouped by code_branch

->select
(
  'a.status as status',
  'b.name as customer_name', 
  'e.name as branch_name' , 
  'c.name as company_name',
  'd.name as project_name',
  'f.name as region_name',
  'e.code as branch_code',
  'e.id as branch_code',
  DB::raw('COUNT(a.id) as total_transaksi')
)
->groupBy
(
  'e.id',
  'b.name',
  'e.name', 
  'e.code',
  'a.status',
  'c.name',
  'd.name',
  'f.name'
)

转到config/database。php

严格设置为假

这是不正确的,不能对相同的列使用单一名称,

  'e.code as branch_code',
  'e.id as branch_code',

改为

  'e.code as branch_code',
  'e.id as branch_id',