procedure TForm1.Button1Click(Sender: TObject);
var Source,sql:string;
begin
if query1.active then query1.close;
query1.sql.clear;
sql:='select field1 from table1 order by field1';// 加上排序字段
query1.sql.add(sql);
try
query1.open;
query1.first;
Source:=query1.fieldbyname('aaa').asstring;
table1.AppendRecord([Source]);
query1.Next;
while not query1.eof do
begin
if query1.fieldbyname('field1').asstring<>Source then
begin
table1.AppendRecord([Source]);
end;
query1.Next;
Source:=query1.fieldbyname('field1').asstring;
end;
finally
query1.close;
end;
end;