lundi 29 avril 2019

Laravel Query builder - multiple sum() issue

Hei there, I'm new in laravel and I have some issues with laravel query builder. The query I would like to build is this one:

Select nofaktur, date, diskon, namacust, SUM(subtotal)+SUM(diskon)) as subtot, SUM(diskon) as totaldiskon, total From crLap GROUP BY nofaktur Order By date, nofaktur.

i've tried like this

$penjualan = DB::table('report_penjualan') ->select('nofaktur', DB::raw('(SUM(subtotal)+SUM(diskon)) as subtot'), DB::raw('SUM(diskon) as totaldiskon')) ->groupBy('nofaktur') ->get()->toArray();

but the field 'date', 'diskon' etc can't be shown..



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2J4RDBB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire