USE NOS_MJDZX drop table #member SELECT gca01c,gak02c,gba03c,gba08c,gsb03c,gcc06f,gae03c into #member FROM gcm01 AS A left join gam10 on gak00c = gca00c and gak01c = gca02c left join gbm01 on gba00c = gca00c and gba01c = gca04c left join gcm03 on gcc00c = gca00c and gca01c = gcc01c and (gcc03i = 2 or isnull(gcc06f,0) != 0) left join gsm02 on gsb00c = gca00c and gsb01c = 'O' and gsb02c = gcc03i left join gam05 on gae01c = gca00c where a.gca00c = a.gca13d and substring(a.gca01c,1,2)<>'散客' and (a.gca08i=4 or a.gca08i=5 or a.gca08i=10) SELECT gca01c as 卡号,gak02c 卡类别,gba03c 姓名,isnull(gba08c,'') 手机,gsb03c 账户,gcc06f 余额,gae03c 公司 from #member where gsb03c != '疗程账户' and gsb03c is not null UPDATE #member SET gba08c = '' where gba08c = 'NULL' SELECT gsb03c,sum(1) from #member group by gsb03c sp_helptext upg_analyzer_customer_order_regdate exec upg_analyzer_customer_order_regdate @class = '*', @compid = '002', @frommemid = '*', @tomemid = '*', @fromdate = '*', @todate = '*', @state = '*', @acon_amt = 0, @alastdate = '*', @at_times = 0, @aav_amt = 0, @aless_remain = 0, @abig_remain = 0, @addtoSMS = 0, @ordertype = 0, @only_card_pay = 0, @memfromdate = '*', @memtodate = ''