--测试数据
declare @t table(姓名 varchar(10),成绩 int,成绩1 int,成绩2 int)
insert into @t
select '张一',90,100,40
union all select '张二',80,80,50
union all select '张三',85,100,40
union all select '张四',85,100,50
--查询
select 姓名
,排名=(select sum(1) from @t where 成绩>=a.成绩 and (成绩1-成绩2)>=(a.成绩1-a.成绩2))
from @t a
order by 成绩 desc,成绩1-成绩2 desc