select id,hit,(select count(*) from d where hit>=t.hit) as b from d t where id=3 order by b
create table k (id int ,hit int) insert k select 1,10 union all select 2,20 union all select 3,30 union all select 4,50 union all select 5,8 union all select 6,70 union all select 7,9若按hit的降序 select h=count(*) from k a where not exists (select hit from k where id=3 and hit<a.hit) 若按hit的升序 总数减h
insert k select 1,10
union all select 2,20
union all select 3,30
union all select 4,50
union all select 5,8
union all select 6,70
union all select 7,9若按hit的降序
select h=count(*) from k a where not exists (select hit from k where id=3 and hit<a.hit)
若按hit的升序
总数减h