How to Find Trends in Public CloudKit Data

I am looking to create a macOS app based on CloudKit. This app would take information, for example, the user's name, (with their permission) and upload it to the app's public CloudKit database. I would then like the app to be able to ask the CloudKit database for the most common first name. How could this be acheived? Thanks!

You could maintain your own counts for each name, incrementing the "Carol" count when a name "Carol" was added, for instance. From that, determining the most common first names would require a sorted fetch of those counts.

How to Find Trends in Public CloudKit Data
 
 
Q