Skip to content
Advertisement

How to calculate the average of total ratings of 5 stars?

I’m trying to get the average rating of total star rating for one restaurant. The customers will rate this restaurant. I made a pivot table for storing customers ratings.

The average rating =5

JavaScript

What is the formula or how can I calculate that in php laravel ?
This is my code:

JavaScript

Advertisement

Answer

Don’t take all place_ratings records out, if there are thousands+ user rate the restaurant, it will slow your API.

Try to use this query:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement