SELECT distinct res.source_business_grp_id + 0 "businessGroupId",
res.source_last_name || ', ' || res.source_first_name || '(' ||
res.user_name || ')' "salesrepFullName",
res.source_email "emailAddress",
res.RESOURCE_ID "salesForceId",
groups.group_name "salesGroupName",
res.source_phone "workTelephone",
res.source_last_name "salesrepLastName",
res.source_id "employeePersonId",
'1' "selectableFlag",
RES.SOURCE_JOB_TITLE "jobTitle",
grprel.GROUP_ID "salesGroupId",
res.source_business_grp_name "businessGroupName"
FROM JTF_RS_RESOURCE_EXTNS RES,
JTF_RS_ROLE_RELATIONS RREL,
JTF_RS_ROLES_VL ROLE,
jtf_rs_groups_tl groups,
JTF_RS_GROUP_USAGES u,
JTF_RS_GROUP_MEMBERS grprel
WHERE (RES.CATEGORY = 'EMPLOYEE' AND
ROLE.ROLE_TYPE_CODE in ('SALES', 'TELESALES', 'FIELDSALES', 'PRM') AND
RREL.ROLE_ID = ROLE.ROLE_ID AND groups.language = userenv('LANG') AND
grprel.GROUP_ID = groups.group_id AND
nvl(rrel.delete_flag, 'N') = 'N' AND
rrel.start_date_active <= sysdate AND
nvl(rrel.end_date_active, sysdate) >= sysdate AND
U.group_id = grprel.group_id AND u.usage = 'SALES' AND
(ROLE.MEMBER_FLAG = 'Y') AND
RREL.ROLE_RESOURCE_TYPE = 'RS_GROUP_MEMBER' AND
grprel.group_member_id = RREL.ROLE_RESOURCE_ID AND
nvl(grprel.delete_flag, 'N') = 'N' AND
RES.RESOURCE_ID = grprel.RESOURCE_ID AND
UPPER(res.source_last_name) LIKE '%' AND
res.source_business_grp_id + 0 = 0)