select distinct parentTerritoryId territoryId from request.qmd_userTerritoryHierarchy where localMarket = 1 select territoryid, name territoryName from tbl_ter_territories where territoryId in ( ) order by name select primaryterritoryid from tbl_fspro_members where fspro_userid = and ownerid = and fsl_tablecode =