adoquery.sql.text:= 'select b ,c from tab order by b '
if recordcount > 0 then
for i:= 0 to recordcount - 1 do
begin
x:= adoquery.fieldbyname('c').asinteger;
y:= adoquery.fieldbyname('c').asinteger;
sql1:= 'c as b' + x + ',';//要去掉最后一个逗号
sql2:= 'b' + x = y;