select opr.recordSource, opr.territoryId, cdr.cdr_territoryId cdr_territoryId, ter.name territoryName, opr.companyName, opr.city, opr.state, opr.zipCode, left( opr.zipCode, 3 ) zip3d, opr.operatorId, dd.accountNumber from tbl_OPR_CLientOperators opr inner join tbl_OPR_DistributionDetails dd on dd.operatorId = opr.operatorId and dd.ownerId = opr.ownerId and dd.ownerType = opr.fsltablecode and nullif( dd.accountNumber, '' ) is not null inner join tbl_CDR_Distributors cdr on cdr.cdr_recordId = dd.cdr_recordId inner join tbl_TER_Territories ter on ter.territoryId = opr.territoryId where opr.ownerId = and opr.fsltablecode = and opr.recordSource like 'Operator Import%' and ( right( opr.recordSource, 4 ) = '2014' or right( opr.recordSource, 4 ) = '2015' ) and nullif( opr.city, '' ) is not null select fseZipCode from tbl_IMPORT_Operators where tempCol = and company_city = and company_state = and eai_batchId = 483638 select *, '' newTerritoryName, 0 newTerritoryId from qmd_subMarkets where possible3d <> zip3d and goofy = 'Y' select ter.ownerId, ter.fsl_tablecode, ter.territoryId, ter.name territoryname from tbl_UT_ZipCodes_3d z3d inner join tbl_TER_ZipCodeLink zcl on zcl.zip3d_id = z3d.zip3d_id inner join tbl_TER_Territories ter on ter.territoryId = zcl.territoryId where z3d.zipCode_3d = and ter.ownerId = and ter.fsl_tablecode = select * from qmd_goofy where (( possible3d <> zip3d ))