数据库中有四张表:Teacher(教师)表、Student

2021-01-05 15:22:39 字数 5799 阅读 8816

1楼:匿名用户

1) select s.name from student s join stucur c on s.id=c.sid

join course cu on cu.id=c.cid where cu.name='自然'

2) select c.name from course c join stucur sc on c.id=sc.cid

join student s on sc.sid=s.id where s.entrancetime between '1999-01-01' and '2012-12-31'

有四张表:student 学生表 ,course 课程表 ,sc成绩表 ,teacher 教师表,求sql语句

2楼:

select sc.* from sc,course where sc.课程号=course.

课程号 and course.课程名='3-105' and sc.成绩 between 60 and 80;

select sc.* from sc where sc.成绩 in(85,56,88);

3. 这个有疑问

我的理解是,学生参加了多门考试,所有成绩都在70-90之间的。取这部分人的学号。

select 学号 from (select 学号,max(成绩) 最高分,min(成绩) 最低分 from sc group by 学号) a where a.最高分 < 90 and a.最低分 >70

3楼:夕夜问情

把需要表进行关联一下 加上条件进行筛选

数据库面试题 有四个表student表,course表,score表,teacher表

4楼:匿名用户

1.select 英语.学

号from score 英语

left join

(select 学号,课程**,成绩

from score where 课程**='数学课程**'

) as 数学

on 英语.学号=数学.学号

where 英语.课程**='英语课程**' and 英语.成绩》数学.成绩

2select student.学号,student.姓名,avg(成绩) as 平均成绩

from score

left join student on student.学号 =score.学号

group by student.学号,student.姓名

having avg(score.成绩)>30

3select student.学号,student.姓名, isnull(选课_成绩.选课数,0) as 选课数,isnull(选课_成绩.总成绩,0) as 总成绩

from student

left join

(select 学号, count(score.课程**) as 选课数,sum(score.成绩) as 总成绩

from score group by 学号

) as 选课_成绩

on student.学号= 选课_成绩.学号

4select a.学号,a.姓名 from student as a

where a.学号 not in(

select distinct(student.学号) as 学号

from student

left join score on score.课程** =

(select course.课程** from course

where course.教师编号 =

(select teacher.教师编号 from teacher

where teacher.教师姓名='王军'))

)仅供学习参考

5楼:匿名用户

题目简单 ,但是头晕,

设在学生数据库中有三张表,表结构如下所示: student(学生表): student表的主键:sno(学号) course(课程

6楼:匿名用户

(1) create table s_c

(sno char(10) not null

,**o char(8) not null

,score int null

,constraint pk_sc primary key (sno,**o)

)(2)insert into student (sno,sname,s***)

values('1010','李小丽','女')

(3)create index ind_**ame on course (**ame)

(4)update student set sage=23 where sno='1005'

(5)delete from course where **ame='管理信息系统'

(6)select **o,**ame,ctime

from course

where teacher='李元'

order by **o asc

(7)select sno,sum(score) as score

from s_c

group by sno

(8)create view v_student

asselect *

from student

where s***='男' and sage>=18 and sage<=24

(9)select sno,sname

from student

where sno in (select sno from s_c where **o='001')

(10)select a.sno,a.sname

from student a

left join s_c b on a.sno=b.sno

left join course c on b.**o=c.**o

where c.**ame='关系数据库'

(11)select sno,sname from

(select a.sno,a.sname,count(1) as count_

from student a

left join s_c b on a.sno=b.sno

group by a.sno,a.sname) a

where count_>3

(12)select c.sname

from

(select * from s_c where **o='002') a

inner join

(select * from s_c where **o='004' on) b on a.sno=b.sno

left join student c on a.sno=c.sno

有四张表 student(s#,sname,sage,***)学生表,course(c#,**ame,t#)课程表,sc(s#,c#,score)成绩表,

7楼:匿名用户

全部通过测试-----第一题

select a.sno,count(a.sno) as 选课数,sum(c.score) as 总成绩

from student as a,course as b,sc as c

where a.sno=c.sno and b.**o=c.**o

group by a.sno

第二题select sno,sname from student

where sno in(

select distinct(d.sno)

from student as d,sc as e

where

d.sno=e.sno and e.sno<>'001' and

e.**o in

(select b.**o

from student as a,course as b,sc as c

where a.sno=c.sno and b.**o=c.**o and a.sno='001'

))第三题

update sc

set score=(select e.cavgscore from(

select **o as classno,avg(score) as cavgscore

from sc

where **o in(

select **o

from course as a,teacher as b

where tname='叶平')

group by **o) as e where classno=**o)

第四题delete from sc

where sc.**o in

(select a.**o

from course as a,teacher as b

where a.tno=b.tno and b.tname='叶平')

8楼:匿名用户

你问题把人看晕了。。。s#、c#、t# 代表什么,相互对应关系标明? 能简单明了的叙述你四个问题吗?这样好帮你。

9楼:匿名用户

这个好像是面试题,我面试的时候有这样类似的题,当时就晕了

有学生头选课系统,数据库中有四个表,分别为: student(s#, sname, sage, s***)

10楼:匿名用户

1select a.s#, avg(b.score) student a,sc b where a.s#=b.s# group by a.s#

having avg(b.score) > 60

2select a.s#, avg(b.score) student a,sc b where a.s#=b.s# and s# in

(select s# from sc where score <60 group by s# having count(*) > 2

)group by a.s#

3select s#,sname from where s# not in

(select a.s# from student a,course b,sc c,teacher d

where

a.s#=c.s# and

b.c#=c.c# and

b.t#=d.t# and

d.tname='叶平')

11楼:

我可提供,baidu hi联系,email? q?

数据库中有3个表:teacher,student,tea—stu,teacher表teaid,name,age,student表stuid,name,age

12楼:匿名用户

1.select b.teald,a.name,count(b.stuld) as 所带学生人内数容

from teacher a,tea-stu bwhere a.teald=b.tealdgroup by b.teald,a.name2.select *

from student a,teacher b,tea-stu cwhere a.stuld=c.stuld and b.

teald=c.teald and a.age>12 and b.

age<40

13楼:匿名用户

你首先要把这2个表关联吧。要不然就直接调用2个表了。。

关系数据库中,关系代表A、数据表B、查询

1楼 匿名用户 习题答案及解析 第6章6 1 1 1 单项选择题 1 c 2 b 3 a 4 d 5 a 6 d 7 a 8 d 9 a 2 多项选择题 1 abcd 2 abcde 3 填空题 关系数据库sql语言? 2楼 匿名用户 先d d 然后group by a b 然后having avg...

一道数据库的题:设有如下三张关系表

1楼 匿名用户 select 姓名 from 学生表 课程表 成绩表 where 课程表 课名 数据库原理 and 课程表 课号 成绩表 课号 and 学生表 学好 成绩表 学好 你学号写成学好了 分拿来。 2楼 匿名用户 select 姓名 from 学生表 left join 成绩表 on 学生...

数据库建立表间关联有什么作用,数据库中表间建立关系后有哪些功能

1楼 匿名用户 可以有一个连带关系,我给你举个例子,一个用户表,一个信息表,一个用户对应多条信息,当你删除用户的时候是不是这个用户的信息也要被删除,如果没有关系的话,你就要在删除用户前手工写条sql语句去删除信息表里的对应信息,如果有关联的话,就不用了,级联删除就可以了,只要删除用户,这个用户下面的...