表:t1,结构为:
id char(4),
num int
如记录:
0001,100
0001,99
0001,99
........
0001,70
现在要查询出结果:
id no1 no2 no3.......no10
0001 100 99 99.........70怎么写啊??有什么好的建议??
id char(4),
num int
如记录:
0001,100
0001,99
0001,99
........
0001,70
现在要查询出结果:
id no1 no2 no3.......no10
0001 100 99 99.........70怎么写啊??有什么好的建议??
1 用新建id自增长字段用来标志行
或用其他表做中间表2 用游标操作
Close;
sql.clear;
sql.add(' select distinct id ');
with query2 do begin
Close;
SQL.Text:='select num from tl order by num ';
Open;
i:=1;
while not eof do begin
query1.SQL.Add(', '+fieldbyname('num').AsString+' as no'+inttostr(i));
i:=i+1;
Next;
end;
end;
SQL.Add(' from tl ');
Open;
end;
id no1.......no10
0001 100 ......100
0001 99.........99