PostgreSQL: five stars rating, ordering objects
问题 In my database users can add a vote from 1 to 5 stars to every groups. Then I have to display a leaderboard by those votes. What I was doing until now is to order them by votes average without a weight. This is not so nice because a group having 5.0 with 20 votes is before of a group having 4.9 avg and 10000 votes. This is my votes table: CREATE TABLE IF NOT EXISTS votes( user_id BIGINT, group_id BIGINT, vote SMALLINT, vote_date timestamp, PRIMARY KEY (user_id, group_id) This is how I sort