vendredi 2 septembre 2016

Eloquent aggregate more than one sum of the same column but different whereIn clause

I want to sum the sum the same column in eloquent but with different whereIn clause in it. Here is my current query it is returning null.

$incomestatement = \DB::table('general_ledger')
                        ->whereBetween("gdate",array($request['incomedatefrom'], $request['incomedateto']))
                        ->select(\DB::raw('sum(glbalance) as salesbalance,general_ledgers.transactionId'))
                        ->whereIn("transactionId",array(67))
                        ->select(\DB::raw('sum(glbalance) as cogsbalance,general_ledgers.transactionId'))
                        ->whereIn("transactionId",array(72,70))
                        ->whereNotIn('transactionId', array(59, 60, 61,62,63,))
                        ->get();

Please help me twist the query if you see the problem. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire