求教,取出某年级某课程第几名的成绩是多少?

guhguh 2003-08-17 04:24:12


成绩表

学号 年级 课程1 课程2
1 3 90 89
2 4 79 59

...全文
75 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjb111 2003-08-17
  • 打赏
  • 举报
回复
create proc P_GradeCourseMC @Grade as int,@Course as varchar(25),@MC as int
--创建一个存储过程@GRADE年级,@Course课程,@MC名次
as
select identity(int,1,1) idd,* into #t from 成绩表 order by @Course Desc
select * from #t where idd=@MC and 年级=@Grade --查询某年级某课程的第几名的记录
drop table #t
Go

调用此存储过程

exec('P_GradeCourseMC 1,'课程1',2')
ylg007 2003-08-17
  • 打赏
  • 举报
回复
select * from where 课程1=(select top3 课程1 from tablename where 年级=3 group by 课程1)
wansijei 2003-08-17
  • 打赏
  • 举报
回复
这只能求出第一条。。如果要求第二条呢??
lynx1111 2003-08-17
  • 打赏
  • 举报
回复
select top 1 * from (select top 3 * from table3 where 年级=3 order by 课程1)a order by 课程1 desc

34,874

社区成员

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

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