Just a suggestion, sometimes it's easier to write separate queries, and a footer that summarizes data.
Usually in a report a final totals summary is a separate query.
Since you are dealing with such things I suggest getting MS Access or LibreOffice base or other and play with some reports to better understand reports.
Bear in mind you have sometimes:
- Running totals
- Final Totals
- Each section totals
All depends on what you need to present. Just examples:
Running sums:

Summary sums:

Basic counting:
$quy = Powner::query()->leftJoin('dc_pets', 'dc_powners.ownerid', '=', 'dc_pets.ownerid')
->select('dc_powners.ownerid', 'dc_powners.oname')
->selectRaw('count(dc_pets.petid) as countOfPets')
->groupby('dc_powners.ownerid')
->orderby('dc_powners.oname')
->get();
Results basically give:
ownerid, oname, countOfPets
Like:
5|Bob|3
4|Greg|9
2|Rob|1
If pagination needed use a lengthawarepaginator.
See https://www.mysqltutorial.org/mysql-count/
And
https://www.mysqltutorial.org/ to look up other good tutorials.