一.分组查询
SELECT MAX(age) FROM student; # 查询年龄最大的数字为32
SELECT * FROM student WHERE age=32; # 查询32的学生信息
SELECT * FROM student WHERE age=(SELECT MAX(age) FROM student); # 利用子查询合并
# like关键字模糊查询:用%代替任意字符,用_代替一个字符
# 查询学生中姓“张”的学生 SELECT * FROM student WHERE sname LIKE '张%';
# 查询学生中姓“李”的学生
SELECT * FROM student WHERE sname LIKE '李__';
# 查询学生中包含“雨”的学生
SELECT * FROM student WHERE sname LIKE '%雨%';
# 查询一班的学生平均年龄
SELECT AVG(age) FROM student WHERE classid=1;
# 查询某个条件下的行数
SELECT COUNT(studentid) FROM student
# 计算C09课程5月的考试平均成绩
SELECT COUNT(studentid) FROM grade WHERE courseid='C09'
AND BETWEEN createtime '2022-05-01' AND '2022-05-31';
标签:语句,age,查询,student,学生,WHERE,SELECT From: https://www.cnblogs.com/eveplw/p/16634389.html