00 Votes

MySQL: Calculate Average

Question by Guest | 2016-07-07 at 13:34

I would like to determine the mean value of all values stored in my MySQL database table "products".

I have already played around a bit with functions like SUM() and COUNT(), but I do not really come to a result. Can someone help me?

ReplyPositiveNegative
1Best Answer1 Vote

You can just use the built in function AVG(). This function is automatically calculating the average value of a column.

You can use it for example like that:

SELECT AVG(price) FROM products

Here, we are calculating the average price taken from the column "price" in the table "products".
2016-07-07 at 20:00

ReplyPositive Negative
Reply

Related Topics

Calculate Hash using PHP

Info | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.