Building a leaderboard

I am stuck on this and I could really use help/nudge in the right direction. Thank you in advance for helping me get unstuck.

In my app, I have a quiz. Users get random questions from a database (that has a table called “Movie_trivia”), they choose an answer and this is recorded in a table called “Movie_trivia_answers”. If the user gets the answer correctly they get one point, if they get it wrong, they get one point deducted.

I would like to show a leaderboard of the top 10 user scores. However, I am getting stuck on the way how to get that out of the database grouped, sorted and calculated properly.

Here are all the tables that are included:

And this is how I was trying to show it as a leaderboard in the UI using a repeater (dynamic list):

I tried several approaches and I only got a partial result with this one. I have successfully generated a calculation of the score by using these blocks:

This logic calculates the difference between all correct and incorrect answers in the table “Movie_trivia_answers”.

And this is the point where I am stuck. I can’t figure out how to group this calculation by user so it is done for each user name separately and then ordered from high to low and then shown in the UI.

Am I even close? Or am I going about this completely wrong? I beg some guidance, please.
My app ID, if needed: BF07EF17-F9B5-DC25-FF43-CC3C042E7500

hello @Miroslav_Sedlacek

you can create a service like the following

With the service, you will get leader board with one call for all users

AHA! Thank you! Works like a charm. Love it! :slight_smile: