以下是一个比较复杂的SQL语句,5000记录要花10秒钟左右:
adoquery6.Close;
adoquery6.SQL.Clear;
adoquery6.SQL.Add('INSERT INTO temp select xsbh,(select count(*)+1 from cy as b where a.总分<b.总分 and left(b.xsbh,5)="C0301" ) as 校名次 from cy as a where left(a.xsbh,5)="C0301"');//计算学校名次,再将xsb和校名次两
          //个字段写入temp表中
adoquery6.ExecSQL;
这句话中left(b.xsbh,5)="C0301",“C0301”为学校代码,当然还有“C0302”、“C0303”所以在我实际程序中还有用到一个循环,所以时间还要长,因此我想做一个等待提示,我要求算出上面程序在何种硬件配置下没有循环需要多少时间?(上面10秒钟是在赛扬2.4G,256Mb上的时间)
这个怎么实现呀? 

解决方案 »

  1.   

    var
    s1,s2:Variant;
    begin
    s1:=GetTickCount;
    adoquery6.Close;
    adoquery6.SQL.Clear;
    adoquery6.SQL.Add('INSERT INTO temp select xsbh,(select count(*)+1 from cy as b where a.总分<b.总分 and left(b.xsbh,5)="C0301" ) as 校名次 from cy as a where left(a.xsbh,5)="C0301"');//计算学校名次,再将xsb和校名次两
              //个字段写入temp表中
    adoquery6.ExecSQL;
    s2:=GetTickCount;
    ShowMessage(FloatToStr((s2-s1)/1000));
    end;
      

  2.   

    adoquery6.Close;
    adoquery6.SQL.Clear;
    adoquery6.SQL.Add('INSERT INTO temp select xsbh,(select count(*)+1 from cy as b where a.总分<b.总分 and left(b.xsbh,5)="C0301" ) as 校名次 from cy as a where left(a.xsbh,5)="C0301"');//计算学校名次,再将xsb和校名次两
              //个字段写入temp表中
    adoquery6.ExecSQL;
    在我实际程序中还有用到一个循环
    你用一个进度条吧,你不是有有循环吗?将他的长度和变化值作为比较就可以得出当前的执行进度了。