How do you get the everage of a mysql table column?
for example:
id | name | age
0 | name1 | 20
1 | name2 | 33
2 | name3 | 18
3 | name4 | 24
I want to get the average of all the ages.
Mysql supports the avg function, which returns the average value.
SELECT avg(age) as average_age FROM tablename
avg() in MySQL faster than returning the results and calculating it with PHP?