
INSERT INTO T_BD_CustomerGroupDetail (FID,FCustomerID,FSTANDARDID, FGROUPID) select fid,fid,712984405228187648,fgroupid from T_BD_Customer where not exists(select fid from T_BD_CustomerGroupDetail where T_BD_Customer.fid = T_BD_CustomerGroupDetail.fCustomerid) and fgroupid <> 0 and (select count(fid) from T_BD_CustomerGroupDetail) = 0 ;