var
i,j : Integer;
ss : array of String;
str,ff : string;
begin
setlength(ss,ADOQuery1.FieldCount);
for i:=0 to ADOQuery1.FieldCount-1 do
begin
if ADOQuery1.Fields[i].DisplayName<>'DISTINCT(列名1)' then
begin
ss[i]:=','+ADOQuery1.Fields[i].DisplayName
end;
end;
for j:=low(ss) to high(ss) do
begin
ff:=ff+ss[j];
end;
str:='select DISTINCT(列名1)'+ff+' from aaa';
end;