-- 一、查询每个专业的学生人数
select count(*) 专业人数,majorid
from student
group BY majorid;
-- 二、查询参加考试的学生中,每个学生的平均分、最高分
select studentno 学号,AVG(score) 平均分,max(score) 最高分
from result
GROUP BY studentno;
-- 三、查询姓张的每个学生的最低分大于60的学号、姓名
select s.studentname 姓名,r.studentno 学号,min(score) 最低分
from result r,student s
where r.studentno=s.studentno
group by r.studentno
having min(score)>60 and substr(s.studentname,1,1)="张";
SELECT s.studentno,s.`studentname`,MIN(score)
FROM student s
JOIN result r
ON s.`studentno`=r.`studentno`
WHERE s.`studentname` LIKE '张%'
GROUP BY s.`studentno`
HAVING MIN(score)>60;
-- 四、查询每个专业生日在“1988-1-
mysql查询综合案例
最新推荐文章于 2024-05-08 10:14:38 发布