2026.11.3mysql作业

查询成绩在80分以上的学生的学号、成绩

select *
from sc
where grade>=80 and sno

查询计算机系年龄在18到20岁之间女生的姓名、年龄

select *
from stu
where sdept='计算机' and sage >=18 and sage <=20 and ssex='女'

查询选修了课程的学生学号(去掉重复行)

select distinct sno
from sc;

查询学生的出生年份

select sno,sname,(year(now())-sage)as 出生年份
from stu;

查询姓王的学生的学号和姓名

select sno ,sname
from stu
where sname like'王%';

查询第二个字是“军”的学生的学号和姓名

select sno,sname
from stu
where sname like '_军%';

查询缺考学生的学号和相应的课程号

SELECT sno,cno
from sc
where grade is null;

查询软件系和计算机系年龄在20-22之间的学生的学号、姓名、年龄和所在系

select sno,sname,sage,sdept
from stu
where sdept in('软件','计算机')and sage between 20 and 22;

posted @ 2026-11-03 20:59  韩雅  阅读(3)  评论(0)    收藏  举报