$data = DB::table('view_term_invoice')
->groupby('tenant_no')
->select(
'tenant_no' ,
DB::raw('count(distinct term_no) as term'),
DB::raw('count(distinct invoice_no) as invoice_no'),
//DB::raw("if(type_inv = 'M',count(distinct invoice_no),0) as invoice_m"),
//DB::raw("if(type_inv = 'T',count(distinct invoice_no),0) as invoice_t"),
DB::raw("sum(distinct grand_total) as grand_total")
)
->get();
当我在db :: raw上运行此查询时,由于if()
内的db::raw
而导致错误
当我在phpmyadmin上运行时我没有问题,
我不明白为什么我突然得到这个错误