Home  >  Q&A  >  body text

sql groupby not working, I want to group 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'
)

P粉021553460P粉021553460194 days ago593

reply all(2)I'll reply

  • P粉428986744

    P粉4289867442024-04-07 15:24:03

    Go to config/database.php

    Strictly set to false

    reply
    0
  • P粉154798196

    P粉1547981962024-04-07 10:38:57

    This is incorrect, you cannot use a single name for the same column,

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

    change to

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

    reply
    0
  • Cancelreply