如何实现数据库的结构转换?
比如:有这个表bz rs ycbt
f50 10 633600
f55 5 244800
m60 35 1209600
转换为
bz f50 f55 m60
rs 10 5 35
ycbt 633600 244800 1209600
请问如何实现?
CREATE CURSOR tb1 (bz c(8),rs c(8),ycbt c(8)) INSERT INTO tb1 VALUES ("f50","10","633600") INSERT INTO tb1 VALUES ("f55","5","1244800") INSERT INTO tb1 VALUES ("m60","35","11209600") AFIELDS(cc) COPY TO ARRAY aa fields rs, ycbt LOCAL bb[ALEN(aa, 2), ALEN(aa, 1)] FOR lnj = 1 TO ALEN(aa) la1 = asubscript(aa, lnj, 1) la2 = asubscript(aa, lnj, 2) bb[la2, la1] = aa[lnj] ENDFOR lcStr = "bz c(10)" lcZdm = "" SCAN lcStr = lcStr + ", " + ALLTRIM(bz) + " c(10)" lcZdm = lcZdm + IIF(EMPTY(lcZdm), "", ",") + ALLTRIM(bz) ENDSCAN CREATE CURSOR tt (&lcStr) FOR lnj = 2 TO ALEN(cc, 1) INSERT INTO tt (bz) VALUES (cc[lnj, 1]) ENDFOR REPLACE FROM ARRAY bb FIELDS &lcZdm ALL BROWSE