求sql ??
table AA
name mark
a 89
b 55
c 20
d 60
我要得到的结果为
name mark id
a 89 1
d 60 2
b 55 3
c 20 4
谢谢拉
------解决方案-------------------- select a.name,a.mark,id=(select count(mark) from tablename where mark> =a.mark) from tablename a
------解决方案--------------------create table AA(name varchar(10), mark int)
insert aa
select 'a ', 89 union all
select 'b ' , 55 union all
select 'c ', 20 union all
select 'd ', 60
select a.name,a.mark,id=(select count(mark) from AA where mark> =a.mark) from AA a order by mark desc