如何用vfp sql语句直接实现下面功能
假设ls dbf表中的数据如下:bmddm sxkmdm xkzh
020100 1 11
020100 1 12
020100 1 11
020100 5 51
020100 5 52
经过SQL语句处理后,ss dbf表中的数据将是:
bmddm sxkmdm xkzh ksrs
020100 1 11,12 3
020100 5 51,52 2
VFP SQL语句如何实现
Create Cursor ls(bmddm c(6),sxkmdm i,xkzh i) Insert Into ls Values('020100',1,11) Insert Into ls Values('020100',1,12) Insert Into ls Values('020100',1,11) Insert Into ls Values('020100',5,51) Insert Into ls Values('020100',5,52) Select bmddm ,sxkmdm,Count(sxkmdm) As ksrs,fn1(bmddm,sxkmdm) As xkzh From ls Group By bmddm ,sxkmdm Proc fn1 Lparameters tc1,tc2 Local lcString lcString = '' Select Distinct xkzh From ls Where bmddm =tc1 And sxkmdm =tc2 Into Curs tmp1 Sele tmp1 Scan All lcString = lcString + ','+Trans(xkzh) Endscan Return Subs(lcString,2)