Not a FMP wiz, just a tech.
List of Functions - Sorted http://www.nightwing.com.au/FileMaker/Resources/FP7_Functions.html
This may be your best bet https://www.google.com/search?q=sql+function+filemaker
SQL Count and Group Forum Question
From this Google https://www.google.com/search?q=group+function+filemaker
Someone with suggestions will be by on Monday, probably.
Take a look at sub summary layout parts. If you sort records by the Group field and specify that this layout part refer to this same field as the "when sorted by" or "break" field, the layout part will appear once for each group of records. If you remove the body layout part from this layout, you'll get one horizontal row for each group. Summary fields in this layout part can compute aggregate values such as a total, average, count,... etc.
There are also ways that can produce this result as lines of data inside a field if you use the ExecuteSQL function in FileMaker 12.