SQL笔记三:MySQL常用函数

1.求一列的最小值:min()  例如,要求学生表中最低的数学分数 select min(score) from student a,grade b where a.id=b.id and b.kemu=“数学”

2.求一列的最大值:max() 例如,要求学生表中的最大年龄 select max(age) from student

3.求一列的平均值:avg() 例如,要求学生表中的平均年龄 select avg(age) from student

4.求一列的和:sum() 例如,要求每个学生的分数总和 select sum(score) from student a,grade b where a.id=b.id group by name

5.求满足条件数据的个数:count(字段)或count(*)表示所有 例如要求统计男学生的个数 select count(*) from student where sex="男"

6.还有一些常用的日期函数和字符串函数,了解即可

未完待续

原文地址:https://www.cnblogs.com/123blog/p/10239864.html