分别用一条SQL语句完成以下题目的操作: 1. 查询年龄为19岁的女同学的学号和姓名

关系数据库中有如下三个关系,其中:Sno:学号,Cno:课程号,Grade:成绩

a) 学生:S(Sno, Sname, Ssex, Sage, Sdept)

其中:Sno:学号,Sname:姓名,Ssex:性别,Sage:年龄,Sdept:系名

b) 课程:C(Cno, Cname, Clocation, Teacher)

其中:Cno:课程号,Cname:课程名,Clocation:上课地点,Teacher:教师

c) 选课:SC(Sno,Cno,Grade)

分别用一条SQL语句完成以下题目的操作:

1. 查询年龄为19岁的女同学的学号和姓名

2. 查询上课地点在主楼的所有课程名称及其上课地点,并按照教师排序

3. 查询“数据库原理”成绩在80分以上(含80分)的学号

4. 查询每个学生的学号、姓名和相应的平均成绩

5. 删除选课人数在10人以下(包括10人)的课程的选课记录

答题要领:

本题考查的是对SQL语言的掌握情况。常用的SQL语句包括选择语句、更新语句、插入语句和删除语句。

选择语句的语法格式为:

select字段名1, …… from 关系名称 where 限定条件

更新语句的语法格式为:

update 关系名称set 字段名1 = 新值, …… where 限定条件

插入语句的语法格式为:

insert into关系名称values (第一个字段值,……)

删除语句的语法格式为:

delete from 关系名称 where 限定条件

1
select sno,sname from s where ssex='女' and sage=19

2
select cname,clocation from c where clocation='主楼' order by teacher

3
select sno from sc where grade>=80 and cno in (select cno from c where cname='数据库原理')

4
select s.sno,s.sname,avg(grade) from s,c,sc where s.sno=sc.sno and c.cno=sc.cno group by s.sno,s.sname

5
selete from sc where cno in (select cno from sc group by cno having count(*)<=10)
温馨提示:答案为网友推荐,仅供参考
相似回答