select T1.SECTION_ID as sectionId, T1.SECTION_NAME as sectionName, T1.SECTION_PRINCIPAL as sectionPrincipal, T1.SECTION_MANAGER as sectionManager, T1.CHANNEL_ID as channelId, T1.CONTACT_PHONE as contactPhone, T1.LATN_ID as latnId, T1.SECTION_TYPE as sectionType, T1.CRT_DATE as crtDate, T1.MOD_DATE as modDate, T1.EMPEE_ID as empeeId, T1.STATE_G as state, T1.ENTITY_ID as entityId, T5.EMPEE_NAME as managerName, (select count(*) from TB_PTY_GRID_SECTION_REL T2, Tb_pty_inter_org T3, TB_PTY_CUST_551 T4 where T1.SECTION_ID = T2.SECTION_ID and T2.GRID_ID = T3.inter_org_id and T3.inter_org_id = T4.REGION_ID and T3.eff_STATE = 'G01' and T3.inter_org_type_id = 1) as customerNum, (select count(*) from TB_PTY_GRID_SECTION_REL T2, Tb_pty_inter_org T3 where T1.SECTION_ID = T2.SECTION_ID and T2.GRID_ID = T3.inter_org_id and T3.eff_STATE = 'G01' and inter_org_type_id = 1 and T3.INTER_ORG_ID in (select t1.inter_org_id inOrgId1 from tb_pty_inter_org_rel t1, tb_pty_inter_org t2, tb_pty_inter_org_rel_type_ref t3, tb_pty_inter_org_struc t4, tb_pty_inter_org_rel t5 where t1.inter_org_id = t2.inter_org_id and t1.inter_org_rel_type_id = t3.inter_org_rel_type_id and t5.inter_org_rel_type_id = t3.inter_org_rel_type_id and t1.INTER_ORG_STRUC_ID = t4.INTER_ORG_STRUC_ID(+) and t1.index_code like t5.index_code || '%' and t1.EFF_STATE = 'G01' and t3.inter_org_rel_type_code = 'CHN_SALES' and t4.inter_org_struc_code = 'REGION' and (t5.inter_org_id = 60396035))) as griddingNum from TB_PTY_GRID_SECTIION T1, TB_PTY_EMPEE T5 where 1 = 1 and T1.SECTION_MANAGER = T5.empee_id and ((checksectionidisperm(T1.SECTION_ID, 'select t1.inter_org_id inOrgId1 from tb_pty_inter_org_rel t1, tb_pty_inter_org t2, tb_pty_inter_org_rel_type_ref t3, tb_pty_inter_org_struc t4, tb_pty_inter_org_rel t5 where t1.inter_org_id = t2.inter_org_id and t1.inter_org_rel_type_id =t3.inter_org_rel_type_id and t5.inter_org_rel_type_id =t3.inter_org_rel_type_id and t1.INTER_ORG_STRUC_ID = t4.INTER_ORG_STRUC_ID(+) and t1.index_code like t5.index_code||''%'' and t1.EFF_STATE=''G01'' and t3.inter_org_rel_type_code = ''CHN_SALES'' and t4.inter_org_struc_code = ''REGION'' and ( t5.inter_org_id = 60396035)') = 1) or T1.Empee_Id = 78 or T1.SECTION_MANAGER = 78) and T1.STATE_G = 'G01' and T1.LATN_ID = 551
|