开发者

PHP/mysql getting average value of a table column

开发者 https://www.devze.com 2023-02-23 05:33 出处:网络
How do you get the everage of a mysql table column? for example: id | name | age 0 | name1 | 20 1 | name2 | 33

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

精彩评论

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