4. 列出“s-01”号课成绩比“s-02”号课成绩高的所有学生的学号
时间:2011-11-19
来源:互联网
1001 s-01 80
1001 s-02 70
1001 s-03 60
1001 s-04 50
1001 s-05 40
1002 s-01 55
1002 s-02 77
1002 s-03 68
1002 s-04 50
1002 s-05 89
1003 s-01 80
1003 s-02 35
1003 s-03 76
1003 s-04 89
1003 s-05 93
作者: a_tuzi 发布时间: 2011-11-19
--> --> (Roy)生成測試數據 if not object_id('Tempdb..#T') is null drop table #T Go Create table #T([学号] int,[课程号] nvarchar(4),[成绩] int) Insert #T select 1001,N's-01',80 union all select 1001,N's-02',70 union all select 1001,N's-03',60 union all select 1001,N's-04',50 union all select 1001,N's-05',40 union all select 1002,N's-01',55 union all select 1002,N's-02',77 union all select 1002,N's-03',68 union all select 1002,N's-04',50 union all select 1002,N's-05',89 union all select 1003,N's-01',80 union all select 1003,N's-02',35 union all select 1003,N's-03',76 union all select 1003,N's-04',89 union all select 1003,N's-05',93 Go Select * from #T as a where [成绩]> (select min([成绩]) from #T where [课程号]='s-02') and [课程号]='s-01' /* 学号 课程号 成绩 1001 s-01 80 1002 s-01 55 1003 s-01 80 */
作者: roy_88 发布时间: 2011-11-19
Select * from #T as a where [成绩]> (select max([成绩]) from #T where [课程号]='s-02') and [课程号]='s-01' /* 学号 课程号 成绩 1001 s-01 80 1003 s-01 80 */
作者: roy_88 发布时间: 2011-11-19
而且我这个每个人都要显示啊。。。
不分组求出来的最大值 是所有成绩中的最大值吧
作者: a_tuzi 发布时间: 2011-11-19
from tb m left join tb n
on m.课程号 = 's-01' and n.课程号 = 's-02' and m.学号 = n.学号 and m.成绩 > isnull(n.成绩,0)
作者: dawugui 发布时间: 2011-11-19
一个项目涉及到的50个Sql语句(整理版)
http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html
作者: dawugui 发布时间: 2011-11-19
- -貌似 你的这个方式不可以啊。。 max是干嘛 最大值啊 我要的是所有的学生啊
而且我这个每个人都要显示啊。。。
不分组求出来的最大值 是所有成绩中的最大值吧
列出“s-01”号课成绩比“s-02”号课成绩高的所有学生的学号
--------------------
表达不清楚时,最好用数据
贴一下以上数据显示结果
作者: roy_88 发布时间: 2011-11-19
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28