在雄辩的laravel上与团队一起计算

时间:2018-02-20 07:34:32

标签: oracle laravel eloquent

您好我在oracle上发了这个查询:

select count(*), queue
from cases
where queue not in ('OPBO_SA_Work-in-Prog','OP_AD_WIN_TECH')
group by queue

这是结果:

18  OP_AD_WIN_ACTIVATION
18  OP_AD_WIN_HARDWARE
4   OP_AD_WIN_FIBER
37  OPBO_WIN_Fiber_pend_i
8   OP_AD_WIN_RELOCATION
47  OPBO_WIN_Act_pend_i

我在laravel上做同样的事情我试试这个:

  'total' => $this->cases->select('queue')->whereNotIn('queue',
['OPBO_SA_Work-in-Prog','OP_AD_WIN_TECH'])->groupBy('queue')->count(),

结果是 18(只有第一个数字)

1 个答案:

答案 0 :(得分:0)

get()而不是count():

$cases = \DB::table('cases')
    ->select(\DB::raw('count(*) as queue_count, queue'))
    ->whereNotIn('queue', ['OPBO_SA_Work-in-Prog','OP_AD_WIN_TECH'])
    ->groupBy('queue')
    ->get();