PHP/mysql getting average value of a table column
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 开发者_JS百科ages.
Mysql supports the avg
function, which returns the average value.
SELECT avg(age) as average_age FROM tablename
精彩评论