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

Time:05-30

->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'
)

CodePudding user response:

It's incorrect, you can't use single name for same columns,

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

change to

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

CodePudding user response:

go to config/database.php

strict set false

  • Related