abcdefg is field:
select (a+b+c+d+e+f+g),(a+b),(c+d),(e+f),g from table1
Get Value:
Over :=Fields[0].AsInteger;
a1 :=Fields[1].AsInteger;
a2 :=Fields[2].AsInteger;
a3 :=Fields[3].AsInteger;
a4 :=Fields[4].AsInteger;

解决方案 »

  1.   

    其实这个问题是这样的:
    其实这是一个报表来的,用户要求是第一页纸只打印两条记录,每一页都要统计一页
    的合计,当在最后一页时有一个统计总合计。我的方法只是这样,只能在一个表
    table1.db里每两条记录插入一个“页合计”,到最后有一个“总合计”,如何实现
    呢?我用中国式报表不能实现这个功能,用sceenreport能实现,但是太麻烦了,不知有没有其它的报表软件?
      

  2.   

      我经过试验,用SQL已经可以实现在数据库中插入页合计,不过在显示上存在问题 ,请把你的具体TABLE的所有字段列示出来,以及唯一索引,字段类型,如果有了这些那么问题就会迎刃而解。
      具体操作如下:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I,SumValue,Value1,Value2,LastValue:Integer;
    begin
      with Table1 do
      begin
        if (Recordcount mod 2)<>0 then
        begin
          Last;
          LastValue:=Fieldbyname('price').AsInteger;
        end;
        First;
        for I:=0 to RecordCount-1 do
        begin
          if (RecNo mod 2)=0 then
          begin
            Value1:=Fieldbyname('price').AsInteger;
            MoveBy(-1);
            Value2:=Fieldbyname('price').AsInteger;
            SumValue:=Value1+Value2;
            MoveBy(1);
            with Query1 do
            begin
              Close;
              Sql.Clear;
              Sql.Add('insert into Record (name,price) values("页合计",'+inttostr(SumValue)+')');
              ExecSQL;
            end;
          end;
          Next;
        end;
        with Query1 do
        begin
          Close;
          if IntToStr(LastValue)<>'' then
          begin
            Sql.Clear;
            Sql.Add('insert into Record(name,price) values("页合计",'+inttostr(LastValue)+')');
            ExecSQL;
          end;
          Sql.Clear;
          Sql.Add('insert into Record (name,price) select "总合计",sum(price) from Record where name="页合计"');
          ExecSQL;
        end;
      end;
    end; 
      

  3.   

    用DELPHI的QUICKREPORT就可以.想了解详细情况,MAIL ME.