开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜