SELECT bm,COUNT(*) 合计 FROM y INTO dbf y2 GROUP BY bm WHERE !EMPTY(bh)
SELECT DISTINCT bh FROM y INTO CURSOR tmp WHERE !EMPTY(bh)
SCAN
czd=ALLTRIM(bh)
ALTER table y2 ADD &czd. n(3)
ENDSCAN
SELECT y2
SCAN
cbm=ALLTRIM(bm)
SELECT bh,COUNT(*) sj FROM y INTO CURSOR tmp GROUP BY bh WHERE ALLTRIM(bm)==cbm AND !EMPTY(bh)
SCAN
czd=ALLTRIM(bh)
REPLACE &czd WITH tmp.sj IN y2
ENDSCAN
ENDSCAN