提取学生的名字???

mainone 2003-06-24 04:56:04
从table(name ,math,score) 中提取出所有分数为第二名的学生的名字???
不可以使用top关键字!!!
...全文
50 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fanmb 2003-06-24
  • 打赏
  • 举报
回复
select tb2.name,tb2.math,max(tb2.score) from
(select a.name,a.math,a.score from tablename a,
(select name ,math,max(score) as score from tablename group by math,name) as tb1
where a.name <> = tb1.name and a.math = tb1.math and a.score < tb1.score) as tb2
group by tb2.math,tb2.name
97866 2003-06-24
  • 打赏
  • 举报
回复
Select name,math,Max(score) From table
where Score=(Select Max(Score) from table
where Score<>(Select Max(Score) from Table))
Group by name,math
愉快的登山者 2003-06-24
  • 打赏
  • 举报
回复
select * from table1 A
where score = (select max(score) from table1
where math = A.math and score < (select max(score) from table1
where math = A.math)
Myyokel 2003-06-24
  • 打赏
  • 举报
回复
select name from table aa
where not exists
(
select 1 from table bb where aa.math=bb.math
and bb.score<
(select max(score) from table cc where bb.math=cc.math)
and bb.score>aa.score
)
CrazyFor 2003-06-24
  • 打赏
  • 举报
回复
select * from table aa where not exists(select 1 from table bb where aa.math=bb.math and bb.score<(select max(score) from table cc where bb.math=cc.math) and bb.score>aa.score)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧