select t.name territoryName, t.territoryId, t.parentTerritoryId, tr.samplefulfillmentcontactid, tr.sampleRushApproverId, tr.ordertypeid, 'sampleFulfillmentContactId' sampleMgmtRole, m.fspro_userid, m.firstName, m.lastName, m.email, #_sequence# sequence
from tbl_TER_Territories t
left outer join tbl_POS_TerritoryResponsibility tr
on tr.ownerId = t.ownerId
and tr.ownerType = t.fsl_tablecode
and tr.territoryId = t.territoryId
and tr.orderTypeId = 58
left outer join tbl_FSPro_members m
on m.fspro_userid = tr.sampleFulfillmentContactId
and m.ownerId = tr.ownerId
and m.fsl_tablecode = tr.ownerType
where t.ownerId = 4839
and t.fsl_tablecode = 'MFR'
and t.territoryId = 11251