c 语言和sql数据库第一章作业答案,简单的SQL语言(数据库作业)

本文档展示了如何通过SQL查询分析张鹏同学的不及格课程、刘洋老师授课学生的筛选、仅男生选的课程、女生必修课程和数据库课程低分学生。涉及课程名称、分数、任课教师以及学号等关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

满意答案

00e27ab806e4881f8254fe7ae8741834.png

Ties丿小锦

2015.05.10

00e27ab806e4881f8254fe7ae8741834.png

采纳率:47%    等级:8

已帮助:166人

12345678910111213141516171819202122232425262728293031323334353637   --⑴ 张鹏同学不及格的那些课程名,以及这些课程的分数、任课教师   select Cn,Score,TEACHER from C join    (   select C# ,score from SC    where S# = (select S# from S where Sn='张鹏' )   ) T   on C.C#=T.C#   --⑵ 选了刘洋老师三门以上课程的学生的学号和姓名   select S#,Sn from S where S# in   (   select S# from SC    where C# in(select C# from C where TEACHER ='刘洋')   group by S#    having COUNT(*)>3   )   --⑶ 只有男生选的课程名称和教师——要求不用集合运算符   select Cn,TEACHER from C    where C# not in   (   select C# from SC    where S# in(select S# from S where  sex='女')   )   --⑷ 全部女生都选了的课程名称   select C# from SC    where S# in(select S# from S where sex='女')   group by C#    having COUNT(*)= (select COUNT(*) from S where sex='女')  -- ⑸ 数据库课程分数低于平均的学生姓名和他的分数  select Cn,Score from C join  (  select C#,Score from SC  where C# =(select C# from C where Cn='数据库')  and Score

是不是在最后加一个

where score>60

??

追答: 恩

select Cn,Score,TEACHER from C join

(

select C# ,score from SC

where S# = (select S# from S where Sn='张鹏' and score<60)

) T

on C.C#=T.C#

追问: 第一题能不能不用连接?

像这样:

select SC.Score, C.TEACHER, SC.CN

from SC, C

where C#=(select c# from s where c#=

( select c# from S Where Sn='张鹏' and score>60))

额,这个应该是错的吧。,,好像C#不在S中

追答: 难道我第一题用的不是连接?

00分享举报

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值