I was wondering if there was an actually good way to aggregate/calculate percentiles based on all data in a database. For example, data like:
{
'name':'John'
'rank':5
},
{
'name':'John'
'rank':4
},
{
'name':'John'
'rank':5
},
{
'name':'James'
'rank':3
},
{
'name':'Froggy'
'rank':5
},
How would I go about finding a way to calculate the percentile that users achieve a specific rarity compared to others. Example: James falls in the top 10% of users who own rank 5.
2
Answers
I think the formula for that would be
(no_of_people_with_rank_5/total_people)*100
. And honestly, it also depends about the logic in database, is it that a person with rank 5 holds all other ranks or are the ranks all separate? For this answer I will assume all ranks are separate.emphasized textYou can do something like:
See how it works on the playground example