2016 - 2024

感恩一路有你

mysql的七个聚合函数 mysql怎么从集合中查询数据?

浏览量:1861 时间:2021-03-11 17:59:30 作者:admin

mysql怎么从集合中查询数据?

1、选中需要测试的数据库,并查看测试数据库表;由于表t_people_info中的id是主键,求id的个数即是求数据库表的总记录数,代码如下:select count(id) from t_people_info

2、查看数据库表t_people_info中年龄中最小值,需要用到集合函数min(),代码如下:select min(p_age) from t_people_info

3、查看数据库表t_people_info中年龄中最大值,需要用到集合函数max(),代码如下:select max(p_age) from t_people_info

4、查看数据库表t_people_info中年龄中平均值,需要用到集合函数avg(),代码如下:select avg(p_age) from t_people_info

5、若想统计t_people_info中的年龄的总和,用到集合函数sum(),代码如下:select sum(p_age) from t_people_info

6、统计数据库表中记录个数,除了使用count(主键)外,可以使用count(1)、count(*)和count(0),代码如下:select count(1) from t_people_infoselect count(*) from t_people_infoselect count(0) from t_people_info

mysql的七个聚合函数 oracle数据库菜鸟教程 java object方法

版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。