怎麽給一個表做匯總??快來呀表qyYnInout
    書籍     book
    數量     quantity效果如下:
   book      quantity
   數據庫      5
   網葉製作    10
   flash       8
               | 
   合計        23合計要在dDBGrid 上顯示合計我要怎麽做?快幫忙。

解决方案 »

  1.   

    select sum(quantity) as total from QyYnInout
      

  2.   

    如果是要在最下面显示合计,写个求和函数,
    function RGrid.CalQtySum(iCol: Integer): Real;
    var i:Integer;
        rSum:Real;
    begin
      rSum:=0;
      for i:=FixedRows to RowCount-1 do
       if (Trim(Cells[iCol,i])<>'') and  (Trim(Cells[iCol,i])<>'-') then
          rSum:=rSum+StrToFloat(Trim(Cells[iCol,i]));
      Result:=rSum;
    end;这是将StringGrid某列求和的函数,
      

  3.   

    用Ehlib的DbGridEh吧,不用写代码,只要在设计时配置好就自动有汇总项了。