数据库多表查询 这4个题都怎么做呀

数据库多表查询 这4个题都怎么做呀,第1张

1

select a.s# from

(select s#,score from sc where c#='001') a

inner join

(select s#,score from sc where c#='002') b

on a.s#=b.s# and a.score>b.score

2

select student.s#,student.sname,count(*) as 选课数,sum(sc.score) 总成绩

from student,course,sc

where student.s#=sc.s#

and course.c#=sc.c#

3

select s@,sname from student where s# not in

(select s# from sc where c# in

(select c# from course where t#=(select t# from teacher where tname='叶平')))

4

select student.s#,student.sname

from

student,course,sc where

student.s#=sc.s#

and course.c#=sc.c#

and sc.c# in

(select c# from course where t#=(select t# from teacher where tname='叶平'))

group by student.s#,student.sname

having count(*)=(select count(c#) from course where t#=(select t# from teacher where tname='叶平'))

1、select a.xh,a.xm,a.xb,b.bjmc from xsb a,bjb b where a.id=b.bjb_id

2、select b.xh,b.xm,b.xb,a.bjmc,c.yw,c.sx from bjb a,xsb b,cjb c where a.id=b.bjb_id and b.id=c.id

3、select a.id,a.bjmc,count(*) from bjb a,xsb b where a.id=b.bjb_id group by a.id,a.bjmc

4、select b.xh,b.xm,a.bjmc,c.yw+c.sx from bjb a,xsb b,cjb c where a.id=b.bjb_id and b.id=c.id and c.yw+c.sx>150

5、select a.id,a.bjmc,avg(c.yw),avg(c.sx) from bjb a,xsb b,cjb c where a.id=b.bjb_id and b.id=c.id group by a.id,a.bjmc


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9669664.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存