Forum Documentation Showcase Pricing Learn more

Ranking by highscores

#1

Hi all,

I hope you can help me. I have a problem that I think could be easy to fix for more experienced users than myself.

I have an app where users are scoring a list of songs (1 = bad song and 5 = top song).

The scores are stored in a database table that looks like this :

USER / SONG / SCORE
userA / songA / 5
userA / songB / 3
userA / songC / 4
userB / songA / 3
userB / songB / 2
userB / songC / 5

Now, I would like to set up a Repeating Group that shows :
songC / Total score 9
songA / Total score 8
songB / Total score 5

And the list should be ranked by highest score.

How do I achieve this?

Thanks for your help!

Jef

#2

Hi Jef, Welcome to Bubble!

You can use the group by operation on top of your search query, and the sort by the sum of the scores. It will look something like this:

First setup the search with any constraints needed. You then add group by, and set the grouping to be the song field, and then use an aggregation to add up all the scores for each song. The sorting is added to the end of the grouping, just use descending on sum of Score.

Good luck!

–Ken



Looking to accelerate your app development?

Development of Advanced Apps at https://uniqueideas.com or schedule a free intro session :gift:

Ken Truesdale
LinkedIn

1 Like
#3

Thanks for the solution.

Now I’m wondering if I can achieve the following.

After several people have scored the songs, I have a database of Scores. Is it possible to make a new database that stores the total score per song? This way the rankings would load more quickly on the webpages, I think.

Hope someone can help me with this.

Thanks,
Jef