1. 程式人生 > >SQL筆記三:MySQL常用函數

SQL筆記三:MySQL常用函數

表示 年齡 where 字符 最小值 sco 要求 筆記 HERE

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.還有一些常用的日期函數和字符串函數,了解即可

未完待續

SQL筆記三:MySQL常用函數