COUNT()函数
1,COUNT()函数用来统计记录的条数;
SELECT COUNT(*) FROM t_grade; SELECT COUNT(*) AS total FROM t_grade;
2,与 GOUPE BY 关键字一起使用;
SELECT stuName,COUNT(*) FROM t_grade GROUP BY stuName;
SUN()函数
1,SUM()函数是求和函数;
SELECT stuName,SUM(score) FROM t_grade WHERE stuName="张三";
2,与 GOUPE BY 关键字一起使用;
SELECT stuName,SUM(score) FROM t_grade GROUP BY stuName;
AVG()函数
1,AVG()函数是求平均值的函数;
SELECT stuName,AVG(score) FROM t_grade WHERE stuName="张三";
2,与 GOUPE BY 关键字一起使用;
SELECT stuName,AVG(score) FROM t_grade GROUP BY stuName;
MAX()函数
1,MAX()函数是求最大值的函数;
SELECT stuName,course,MAX(score) FROM t_grade WHERE stuName="张三";
2,与 GOUPE BY 关键字一起使用;
SELECT stuName,MAX(score) FROM t_grade GROUP BY stuName;
MIN()函数
1,MIN()函数是求最小值的函数;
SELECT stuName,course,MIN(score) FROM t_grade WHERE stuName="张三";
2,与 GOUPE BY 关键字一起使用
SELECT stuName,MIN(score) FROM t_grade GROUP BY stuName;