如何排名??急!!!(35分)

P

pckite

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟现有个问题, 如何排名??急!!!
假如表里已经有了数据,我想按字段“分数”进行排名,并把排名写入对应
的字段“名次”中,如何实现?

 
你的是什么数据库?
 
在事件中加上:
adoquery1.Sort:='分数';
即可从小到大排名。
然后
adoquery1.last;
for i:=1 to adoquery1.recordcount do
begin
adoquery1.edit;
adoquery1.fieldbyname('名次').value:=inttostr(i);
adoquery1.post;
adoquery1.prior;
end;
 
delphi5+ado+access2000
用SQL语句取出成绩排名顺序,同时考虑了同分名次相同的状况

select (select count(分数)+1 from table1 t2 where t2.分数>t1.分数) as 名次,名字,分数
from table1 t1
order by 分数 desc

 
或许你去参考一下,也是成绩排序的
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1207912
 
是要自己算
 
顶部