select distinct 數學成績 into #a from 表 select top 3 * from tablename order by 数学成绩 desc select top 3 * into #b from #a select * from 表 where 表.數學成績=#b.數學成績 drop table #a,#b
select distinct 數學成績 into #a from 表 select top 3 * from 表 order by 数学成绩 desc select top 3 * into #b from #a select * from 表 where 表.數學成績=#b.數學成績 drop table #a,#b
select top 3 with ties from 表 order by 数学成绩 desc
--上边的有点问题!select top 3 with ties * from tb order by id desc--加上with ties关键字就可以把相同的成绩也显示出来了
select distinct b into #a from a select * from a where a.b in (select top 3 T.* from #a T order by T.b desc) drop table #a 這個已經經過測試,能行
select all top 3 * from tablename order by 数学成绩 desc
select top 3 * from tablename order by 数学成绩 desc 这样可以,不过如果有相同成绩的超过3人怎么办?你是要解决这样的问题吗?
select top 3 with ties * from tb order by 数学成绩 desc
select top 3 * from tablename order by 数学成绩 desc
select top 3 * into #b from #a
select * from 表 where 表.數學成績=#b.數學成績
drop table #a,#b
select top 3 * from 表 order by 数学成绩 desc
select top 3 * into #b from #a
select * from 表 where 表.數學成績=#b.數學成績
drop table #a,#b
select * from a where a.b in (select top 3 T.* from #a T order by T.b desc)
drop table #a
這個已經經過測試,能行
这样可以,不过如果有相同成绩的超过3人怎么办?你是要解决这样的问题吗?