设置一游标,将所需记录数据全部读入,
然后开始一循环,如:name(n) 数组,rowcount = 记录总数for i=1 to i= rowcount
...... if name(i+1)=name(i) then
.......
end if
......next i
然后开始一循环,如:name(n) 数组,rowcount = 记录总数for i=1 to i= rowcount
...... if name(i+1)=name(i) then
.......
end if
......next i
rs.movenext
if strname=rs.fields("下一条记录的NAME") then
........
end if这样行不?
请大家再作指点,谢谢
rs.open();
while(!rs.eof())
{
name1=rs.GetFieldValue(0);
rs.movenext();
name2=rs.GetFieldValue(0);
if(name1=name2) then
....
}行不?
这里有一个组,它有很多成员,组里面又分了很多队,每个队有一个组长
我要按业绩进行两次排名,一次是对整个组进行排名,一次是对每个队进行排名,这样我可以得到一个表,其中一条记录对应两个排名
我的想法是,全组的排名比较好办
用replace rank with recn()就可以做到
但是对每个队内部的排名怎么做呢,先Order by 队长NAME,然后在每条记录的往下找,如果队长NAME 不同了,则表示是另一个队的成员了,再用循环进行排名,但是上下记录的NAME等不等同,我不知道怎么写这个语句,我用的是VFP,谢谢大家指点,比较紧急。
然后逐条对比。 如果不等,dname = 当前记录的队长名
你不是用order by 吗,总会有第一条记录吧,取出来赋值给变量不就行了吗?
我的意思是 你想要前端编程实现你的目的 还是 后台数据库自动完成目的。做法不同的。我觉得你是想在前端通过程序得到你的结果,对不对?
rs.movenext
while rs.eof=false
if strname=rs.fields("NAME") then
........
end if
strname=rs.fields("NAME")
rs.movenext
wend
replace all rank with recn()
go top
public name,rank
name=fname
rank=1
replace frank with rank
skip
do while fname=name
if !eof()
replace frank with rank+1
else
replace frank with 1
name=fname
skip
endif
enddo
这样写错在哪里?表也打不开,为什么
select 10000-10000 as mc,name,……from tablename order by yj desc into table newtable
sele newtable
repl all mc with recno()
go top
brow
select 10000-10000 as mc,队号,sum(yj) as yj from tablename order by yj desc into able newtablesele newtable
repl all mc with recno()
select 1000-1000 as mc,队号,name,yj…… from tablename order by 队号,yj desc into table newtable
sele newtable
go top
aa=0
c队号=队号
do while not eof()
if 队号=c队号
aa=aa+1
else
aa=1
c队号=队号
endif
repl mc with aa
skip
enddo