Skip to content
Advertisement

Get average of average columns in mysql

I am having a table that stores ratings of a restaurant. As shown in the below image.

enter image description here

I am trying to get the average of all these columns in which I am being successful but I also want an average of all these averages as a main average.

I tried the below query but I am getting 3 as average rating which is not accurate. I think mysql is returning me a round value of the final result.

JavaScript

When I run the above query I get 3 as average for rating field.

enter image description here

The actual result would be 3.42.

Please help me understand what I am doing wrong and what can be done to achieve accurate result. Thanks

Advertisement

Answer

Just add AVG to calculate rating:

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