A
A
arab7892015-04-09 11:16:43
Yii
arab789, 2015-04-09 11:16:43

How to implement product rating?

Please tell me the algorithm for calculating the rating of a product from 5 "stars". How is the average value calculated?
Suppose we have 270 responses (5* - 124, 4* - 57, 3* - 37, 2* - 33, 1* - 19) the average is 3.9. How to get this number?
Or who has simpler rating calculation algorithms?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
arab789, 2015-04-09
@arab789

Found a solution. The number of votes for each "asterisk" is multiplied by the value of this "asterisk", then we sum up the obtained values ​​and divide by the total number of votes.

I
IceJOKER, 2015-04-09
@IceJOKER

AVG(expr)
    Возвращает среднее значение аргумента expr:

    mysql> SELECT student_name, AVG(test_score)
            FROM student
            GROUP BY student_name;

www.mysql.ru/docs/man/Group_by_functions.html

V
vyachin, 2015-04-09
@vyachin

And you can also take into account the time, the last estimate has more weight than the previous one. But such a rating should be stored next to the product and recalculated periodically or after a new rating is given.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question