select firstWord, count(*) matches, sum( linked ) links from ( select SUBSTRING(companyName,1,(CHARINDEX(' ',companyName + ' ')-1)) firstWord, case when fsl_choId > 0 then 1 else 0 end linked from tbl_OPR_ClientOperators with (nolock) where ownerId = and fsltablecode = 'DST' ) x group by firstWord having count(*) > 1 order by matches desc select dstId, dstName from tbl_DST_Distributors dst with (nolock) where exists ( select * from tbl_OPR_CLientOperators opr with (nolock) where opr.fsltablecode = 'DST' and opr.ownerId = dst.dstId ) order by dstName
First WordMatchesNot Linked
#htmleditformat( _firstWord )##lsnumberformat( matches )##lsnumberformat( matches - links )#view
select opr.operatorId, opr.companyName, opr.mfrCustNum, opr.address, opr.address2, opr.city, opr.state, opr.zipcode, opr.recordSource, coalesce( opr.lastUpdated, opr.dateCreated ) lastUpdated, opr.fsl_choId, cdr.fsl_dstId, cdr.cdr_dstName from tbl_OPR_ClientOperators opr with (nolock) left outer join tbl_CDR_Distributors cdr with (nolock) on cdr.ownerId = opr.ownerId and cdr.fsl_tablecode = opr.fsltablecode and cdr.cdr_recordId = opr.distrib1 where opr.ownerId = and opr.fsltablecode = 'DST' and opr.companyName like order by opr.companyName
Matches for: #htmleditformat( url.firstWord )#
Acct Nbr#Name/Source Address Pri. Dist. Last Updated 1FS
#htmleditformat( mfrCustNum )# #htmleditformat( companyName )#
#htmleditformat( recordSource )#
#htmleditformat( address )#
#htmleditformat( address2 )#
#htmleditformat( city )#, #htmleditformat( state )# #htmleditformat( zipcode )#
#htmleditformat( cdr_dstName )#
not mapped
#lsdateformat( lastUpdated )# select z3d.zipCode_3d, count(*) instances from tbl_TER_ZipCodeLink zcl with ( nolock) inner join tbl_UT_ZipCodes_3d z3d with (nolock) on z3d.zip3d_id = zcl.zip3d_id inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_territoryId = zcl.territoryId inner join tbl_DST_Distributors dst on dst.dstId = cdr.fsl_dstId inner join tbl_UT_States ds with (nolock) on ds.state = dst.dstState inner join tbl_UT_States cs with (nolock) on cs.uscensus_division = ds.uscensus_division and cs.state = z3d.zipState where dst.dstId = and cdr.ownerId > 0 and cdr.fsl_tablecode = 'BRO' group by z3d.zipCode_3d select cho_Id, cho_name, cho_dbaName, cho_address, cho_address2, cho_city, cho_state, cho_zipcode , 0+ case when cho_name like then 1 else 0 end as score , case when exists ( select * from tbl_OPR_CLientOperators opr with (nolock) where ownerId = and fsltablecode = 'DST' and opr.fsl_choId = cho.cho_id ) then 1 else 0 end as aleradyLinked from tbl_CHO_Operators cho with (nolock) where cho_name like and ( nullif( cho_zipcode, '' ) is null or left( cho_zipCode, 3 ) in ( ) ) and not exists ( select * from tbl_OPR_CLientOperators opr with (nolock) where ownerId = and fsltablecode = 'DST' and opr.fsl_choId = cho.cho_id ) and ( 0+ case when cho_name like then 1 else 0 end ) > 1 order by score desc, cho_name
#score#
#htmleditformat( cho_address )#
#htmleditformat( cho_address2 )#
#htmleditformat( cho_city )#, #htmleditformat( cho_state )# #htmleditformat( cho_zipcode )#
select cho_Id, cho_name, cho_dbaName, cho_address, cho_address2, cho_city, cho_state, cho_zipcode , 0+ case when cho_name like then 1 else 0 end as score from tbl_CHO_Operators where cho_id =
#htmleditformat( qmd_possibleMatches.cho_name )##qmd_possibleMatches.score#
#htmleditformat( qmd_possibleMatches.cho_address )#
#htmleditformat( qmd_possibleMatches.cho_address2 )#
#htmleditformat( qmd_possibleMatches.cho_city )#, #htmleditformat( qmd_possibleMatches.cho_state )# #htmleditformat( qmd_possibleMatches.cho_zipcode )#