大家帮写一下sql语句!
时间:2011-12-14
来源:互联网
S (SNO,SNAME) 学生关系。SNO 为学号,SNAME 为姓名
C (CNO,CNAME,CTEACHER) 课程关系。CNO 为课程号,CNAME 为课程名,CTEACHER 为任课教师
SC(SNO,CNO,SCGRADE) 选课关系。SCGRADE 为成绩
列出“1”号课成绩比“2”号同学该门课成绩高的所有学生的学号和姓名
作者: suiyuan20042003 发布时间: 2011-12-14
或者简化成一个简单的原表
作者: cqf254112311 发布时间: 2011-12-14
select sno,sname from sc where id not in (select id from sc where 1号课大于二号课成绩)
里面不会写了!
作者: yuan521929 发布时间: 2011-12-14
作者: szstephenzhou 发布时间: 2011-12-14
select sno,sname from SC where (select SCGRADE from SC where (select CNO from C where CNO=1))> ( select SCGRADE from SC where (select CNO from C where CNO=2))
不知道是不是
作者: o274274 发布时间: 2011-12-14
作者: suiyuan20042003 发布时间: 2011-12-14
select S.SNO,S.SNAME
from S
left join SC on S.SNO=SC.SNO
where SC.CNO='1'
and SC.SCGRADE>(select SCGRADE from SC where CNO='1' and SNO='2')
作者: wsdaijianjun 发布时间: 2011-12-14
这句话我还没读懂,我读了3遍了。
作者: jinfengyiye 发布时间: 2011-12-14
作者: suiyuan20042003 发布时间: 2011-12-14
作者: szstephenzhou 发布时间: 2011-12-14
select * from S a where exists(select 1 from sc b where sno=a.sno and cno=1 and exists(select 1 from sc where sno=a.sno and cno=2 and scgrade<b.scgrade))
作者: qianjin036a 发布时间: 2011-12-14
create table s(sno int,sname varchar(10)) insert into s select 1,'aa' insert into s select 2,'bb' create table sc(sno int,cno int,scgrade int) insert into sc select 1,1,80 insert into sc select 1,2,70 insert into sc select 2,1,80 insert into sc select 2,2,90 go select * from S a where exists(select 1 from sc b where sno=a.sno and cno=1 and exists(select 1 from sc where sno=a.sno and cno=2 and scgrade<b.scgrade)) /* sno sname ----------- ---------- 1 aa (1 行受影响) */ go drop table s,sc
作者: qianjin036a 发布时间: 2011-12-14
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28