如何将同一姓名地址的某一字段内容放到一起
如:xm dz bza ssdd aa
a ssdd bb
a ssdd cc
b ssdd b1
b ssdd a1
整理成:
xm dz bz
a ssdd aa,bb,cc
b ssdd b1,a1
该如何写程序啊?
CLOSE ALL SET SAFETY OFF CREATE TABLE T2 FREE ; (Xm C(1), Dz C(4), BZ C(20)) SELECT 0 USE T1 INDEX ON Xm+Dz TAG XmDz GO TOP SCAN 参照关键字=T1.Xm+T1.Dz IF RECCOUNT("T2")=0 INSERT INTO T2 VALUES (T1.Xm, T1.Dz, T1.Bz-",") ELSE IF T2.Xm+T2.Dz=参照关键字 GO BOTTOM IN T2 REPLACE T2.Bz WITH T2.Bz-T1.Bz-"," ELSE SELECT T2 GO BOTTOM REPLACE T2.Bz WITH LEFTC(T2.Bz,LENC(ALLTRIM(T2.Bz))-1) INSERT INTO T2 VALUES (T1.Xm, T1.Dz, T1.Bz-",") SELECT T1 ENDIF ENDIF ENDSCAN SELECT T2 GO BOTTOM REPLACE T2.Bz WITH LEFTC(T2.Bz,LENC(ALLTRIM(T2.Bz))-1) SET SAFETY ON CLOSE ALL RETURN
SELECT DISTINCT XM,DZ,SPACE(20) BZ FROM OKY INTO CURSOR TEMP READWRITE SELECT OKY SCAN UPDATE TEMP SET BZ=ALLTRIM(BZ)+IIF(EMPTY(BZ),[],[,])+OKY.BZ WHERE TEMP.XM==OKY.XM AND TEMP.DZ==OKY.DZ ENDSCAN SELECT TEMP BROWSE