不用临时表:
select 1+isnull(count(*),0) as MC from
(
select stu_id,sum(score) as score from tablename group by stu_id
) as a
where score <(select sum(score) as score from tablename where stu_id='某一个学生'
)最快的方法:select IDENTITY(int,1,1) as id,stu_id,sum(score) as score into #Temp from tablename group by stu_id order by sum(score) descselect id from #Temp where stu_id='某一个学生'
select 1+isnull(count(*),0) as MC from
(
select stu_id,sum(score) as score from tablename group by stu_id
) as a
where score <(select sum(score) as score from tablename where stu_id='某一个学生'
)最快的方法:select IDENTITY(int,1,1) as id,stu_id,sum(score) as score into #Temp from tablename group by stu_id order by sum(score) descselect id from #Temp where stu_id='某一个学生'
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货