DB::table('reserv as r')
->selectRaw('
ch.code as name,
round(sum(rd.balance),2) as value
')
->groupBy('name')
->get();
[
'value'=1,
'value'=2,
'value'=3,
'total'=6
]
select
coalesce(name, 'total') name,
sum(`value`) as value_sum
from reserv
group by name
with rollup;
<?php
$res = DB::table('reserv as r')
->selectRaw('
coalesce(name, "total") name,
sum(`value`) as value_sum
')
->groupBy(DB::raw('name with rollup'))
->get();
print_r($res);