select SUM(要统计的字段) as 新的命名 from 表名 where 条件
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
             毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
  I := TI.Create(Nil);
I.Maxim := MaximStr;
I.Explain := '假如上述代码中出现“OA”、“3D”等字样,改为“=”等';
I.Desire := '加不加分随你';
—————————————————————————————————
       

解决方案 »

  1.   

    后台:
    declare @a int
    select @a = sum(col1) from table1 where ...前台:
    var 
    a : integer;
    with tadoquery.create(nil) do
    begin
    try
      connection := your_conn;
      sql.add('select sum(col1) from table1 ');
      active := true;
      a:= fields[0].asinteger;
    finally
      free;
    end;
      

  2.   


    楼上的挺人个性的哦 :(Decalre @变量名 变量类型;select @变量名=SUM(要统计的字段) from 表名 where 条件
      

  3.   


    唉呀,firetoucher这么快呀,我是说,楼楼楼上的那个了 :-)