第2次上机试题

1.查询年龄在20-23岁之间(不含20与23岁)的学生姓名,系别,年龄(当前年2010) 
SELECT sname,sdept,(2010-year(csrq)) AS age
FROM student
WHERE (2010-year(csrq))>20 AND (2010-year(csrq))<23

2.查询选修过1或3号课程且成绩大于等于80分的所有学生的学号(不许重复)
SELECT distinct sno
FROM sc
WHERE (cno='1'OR cno='3') and grade>=80

3.请将选修了1号课或3号课课程的同学情况按课程号升序,成绩降序排序 
SELECT *
FROM sc
WHERE cno='1' OR cno='3'
ORDER BY cno, grade DESC;

4.请将选了1号课程且成绩在60分以上的同学按成绩降序排序,并将学号,成绩显示出来
SELECT sno, grade
FROM sc
WHERE cno='1' AND grade>60
ORDER BY grade DESC;


5、查询英语系的所有三字名字同学的姓名
select sname
from student
where sdept='英语系' and sname like '___'

6、查询管理系所有非李姓的2009级同学情况
select *
from student
where sname not like '李%' and sno like '2009%' and sdept='管理系'

7、查询所有两字姓名的张姓85年后出生男同学的姓名,性别及出生日期
select sname,sex,csrq
from student
where sname like '张_' and sex='男' and year(csrq)>=1985

8、查询名字中第3个字为铃4月4号出生的学生的姓名和学号
select sname,sno
from student
where sname like '__铃%' and month(csrq)=4 and day(csrq)=4

9、请将选了最后一字为'统'的且学分数在3及以上的所有课程的课程名及学分
select cname,ccredit
from course
where cname like '%统' and ccredit>=3

10、 查询8月8日出生的90后学生的名字及生日(注含1990)
select sname,csrq
from student
where month(csrq)=8 and day(csrq)=8 and year(csrq)>=1990





相关文档
最新文档