select g.longitude, g.latitude, count(*) dupCount from tbl_GEO_Locations g inner join tbl_OPR_CLientOperators o on o.operatorId = g.partnerId and o.ownerId = g.ownerId and o.fsltablecode = g.ownerType where coalesce( g.longitude, 0 ) <> 0 and coalesce( g.latitude, 0 ) <> 0 and g.ownerId = and g.ownerType = and g.partnerType = 'OPR' and o.mergeIntoOperatorId is null -- and o.operatorId not in ( select partnerid from tbl_CRM_Participants where marketingActivityId in ( 1219,1224,1220,1222,1221,1223 ) and partnerType = 'OPR') group by g.longitude, g.latitude having count(*) >= 2 select distinct opr.operatorId, opr.companyName, opr.address, opr.city, opr.state, opr.zipCode, opr.crmActive, case when m.fspro_userid is not null then 'Y' else 'N' end as assigned from tbl_OPR_ClientOperators opr left outer join tbl_FSPro_members m on m.fspro_userid = opr.mfr_bsr_id and m.ownerId = opr.ownerId and m.fsl_tablecode= opr.fsltablecode inner join tbl_GEO_Locations geo on geo.ownerId = opr.ownerId and geo.ownerType = opr.fsltablecode and geo.partnerType = 'OPR' and geo.partnerId = opr.operatorId where geo.ownerId = and geo.ownerType = and geo.longitude = and geo.latitude = and opr.operatorId not in ( ) and opr.mergeIntoOperatorId is null order by opr.crmActive desc, assigned desc, opr.operatorId desc
#_pass#: #_lon# #_lat#: #htmleditformat( _keepCompanyName )# v. #htmleditformat( companyName)# = #lsnumberformat( _companyNameDistance )#
update tbl_OPR_ClientOperators set mergeIntoOperatorId = where operatorId =