You might want to check out the
Merge Records By Category Using Two Keys implementation in my
Microsoft Word Catalogue/Directory Mailmerge Tutorial:
https://www.msofficeforums.com/word/...-tutorial.html
The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it.
Since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire.