Hi,
when I try to extend a Sprunje query using a group by
like this:
$sprunje->extendQuery(function($query) use ($start, $end){
return $query
->select('a.*', 'hc_v.date', 'hc_v.id as id_v', DB::raw('COUNT(*) as num_v'), 'a.id as id_a', 'a.name as az_name', 'm.id as id_m', 'mt.desc as mtdesc' )
->join('hc_b as b', 'id_b', '=', 'b.id')
->join('hc_m as m', 'b.id_m', '=', 'm.id')
->join('hc_a as a', 'm.id_a', '=', 'a.id')
->join('hc_mv as mv', 'hc_v.id', '=', 'mv.id_visita')
->join('hc_mt as mt', 'mv.id_mt', '=', 'mt.id')
->whereBetween('hc_v.date', [$start, $end])
->groupBy('a.id', 'mv.id_m');
});
return $sprunje->toResponse($response);
then the count
and count_filtered
properties into the response are wrong, because they are related to the number of results before grouping (eg. before the group by
the select
retrieves 26 rows, but when I group them I should have just 1 row). Items in rows
are correct, just the counters are wrong.
Please, could you check?