with adoquery do
begin
close;
sql.text := ' select * from table where 1 =2 ';
open; //取回所有字段
for i := 0 to fieldcount -1 do //0是要汇总的字段起点
if s = '' then
s := fieldname
else
s := s + '+' +fieldName
s := 'sum(' + s + ') as hj'; //行汇总
close;
sql.text := ' select ' + s + ' from table ';
open;
end
procedure TPosStatiCls.btn1Click(Sender: TObject);
var
s:String;
i:Integer;
begin
with adoquery1 do
begin
close;
sql.text := ' select * from appel where 1 =2 ';
open; // recuperer tous les fields
for i := 0 to fieldcount -1 do // a partir de 0
if s = '' then
s := Fields.fieldname
else
s := s + '+' +Fields.fieldName;
ShowMessage(s);
s := 'sum(' + s + ') as hj'; // sum(app_1+app_2+...+app_50+app_desc)
close;
sql.text := ' select ' + s + ' from table ';
open;
end
end;