在一个表中,要取出特定的值。例如,一个表(GZ)的字段如下:
编号 月份  合计
p1    8                89
p1    9                88 如何把8月的合计值取出来赋给一个变量?谢谢各位了:)

解决方案 »

  1.   

    select Sum(合计) as hj from GZ
      

  2.   

    我只知道这样可以取
    syz:=ADOGZ.fieldbyname('合计').asfloat;要是具体的取 p1 8月的我就不太清楚了请指教一下
      

  3.   

    with ADOGZ do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select Sum(合计) as hj from GZ where 月份 = 8');
      Open;
      syz := ADOGZ.fieldByName('hj').Value;
    end;
      

  4.   

    with ADOGZ do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select 合计 from GZ where 月份 = 8');
      Open;  syz:=ADOGZ['合计'];
    end;