一(聚合函数)
1.avg() 返回某字段的平均值
eg:查询英雄的平均等级 (别名可加可不加)
select avg(level) '平均等级' from t_hero;
2.count() 统计某字段的行数
eg:查询一共有多少个英雄
select count(*) '英雄的数量' from t_hero;
3.max() 返回某字段的最大值
eg:查询出最高的成长值
select max(growth) from t_hero;
4.min() 返回某字段的最小值
eg:查询最低的成长值
select min(growth) from t_hero;
5.sum() 返回某字段的和
eg:统计出英雄等级的总和
select sum(level) from t_hero;
二(日期时间函数)
6.获取当前日期:select curdate();
7.获取当前的时间:select curtime();
8.获取当前日期和时间:select now();
9.查询指定日期是一年中的第几周:select week('2022-01-10');
10.查询当前时间是一年中的第几周:select week(now(