Can I do a join in a select statement that is formatted for OLE?
I am not having much luck in trying it. The whole thing locks up on me. Here is code that runs fine under ORACLE SQL. Now I need to use it in EXCEL. Please help me to do it. The objective is to get the JOIN to work.
Thanks.
SELECT spriden_id, spriden_last_name||', '||spriden_first_name||' '||spriden_mi,
PEBHSIN_INCIDENT_DATE, PEBHSIN_DESC, PEBHSIN_INCIDENT_DATE, lpad(PEBHSIN_NO,6,0),
PERHSIP_OSHA_IND, PERHSIP_WORK_COMP_IND, perhsip_posn, a.nbrjobs_orgn_code_ts,
ftvorgn_title, ztrhsbc_activity_date,ztrhsbc_bwc_claim_no, perhsim_hsme_code, perhsim_begin_date, perhsim_end_date, perhsim_hours_lost, perhsim_hours_work_restricted, ptrhsme_desc, sysdate
FROM ftvorgn, pebempl, SPBPERS, nbbposn, nbrjobs a, SPRIDEN, perhsim, ztrhsbc, PTRHSIL, ptrhsme, PERHSIP, PEBHSIN
WHERE (ztrhsbc_hsin_no = PEBHSIN_NO) And (PTRHSIL_CODE = PEBHSIN_HSIL_CODE) And (PERHSIP_HSIN_NO = PEBHSIN_NO)
and nbbposn_posn = a.nbrjobs_posn AND (FTVORGN_orgn_code = a.nbrjobs_orgn_code_ts
and ftvorgn_coas_code = 'C' and (to_char(ftvorgn_nchg_date,'DD-MON-YYYY') = '31-DEC-2099'))
and a.nbrjobs_pidm = pebempl_pidm and a.nbrjobs_effective_date in (select max(b.nbrjobs_effective_date)
FROM nbrjobs b where a.nbrjobs_posn = b.nbrjobs_posn and a.nbrjobs_pidm = b.nbrjobs_pidm and a.nbrjobs_pidm = b.nbrjobs_pidm)
and a.nbrjobs_pidm = spriden_pidm and (spriden_change_ind is NULL)
and spriden_entity_ind = 'P' and a.nbrjobs_posn = perhsip_posn
and (TO_CHAR(ztrhsbc_activity_date,'MM/DD/YYYY')) >= &nbidate
and (TO_CHAR(ztrhsbc_activity_date,'MM/DD/YYYY')) <= &neidate
and perhsim_hsme_code = ptrhsme_code and SPBPERS_PIDM = a.nbrjobs_PIDM AND a.nbrjobs_PIDM = PERHSIP_PIDM
and perhsim_pidm = spriden_pidm(+)
and perhsip_pidm = perhsim_pidm(+) GROUP BY spriden_id, spriden_last_name, spriden_first_name, spriden_mi,
PEBHSIN_INCIDENT_DATE, PEBHSIN_DESC, PEBHSIN_INCIDENT_DATE, lpad(PEBHSIN_NO,6,0), PERHSIP_OSHA_IND, PERHSIP_WORK_COMP_IND, perhsip_posn, a.nbrjobs_orgn_code_ts,
ftvorgn_title, ztrhsbc_activity_date, ztrhsbc_bwc_claim_no, perhsim_hsme_code, perhsim_begin_date, perhsim_end_date, perhsim_hours_lost, perhsim_hours_work_restricted, ptrhsme_desc, sysdate
I am not having much luck in trying it. The whole thing locks up on me. Here is code that runs fine under ORACLE SQL. Now I need to use it in EXCEL. Please help me to do it. The objective is to get the JOIN to work.
Thanks.
SELECT spriden_id, spriden_last_name||', '||spriden_first_name||' '||spriden_mi,
PEBHSIN_INCIDENT_DATE, PEBHSIN_DESC, PEBHSIN_INCIDENT_DATE, lpad(PEBHSIN_NO,6,0),
PERHSIP_OSHA_IND, PERHSIP_WORK_COMP_IND, perhsip_posn, a.nbrjobs_orgn_code_ts,
ftvorgn_title, ztrhsbc_activity_date,ztrhsbc_bwc_claim_no, perhsim_hsme_code, perhsim_begin_date, perhsim_end_date, perhsim_hours_lost, perhsim_hours_work_restricted, ptrhsme_desc, sysdate
FROM ftvorgn, pebempl, SPBPERS, nbbposn, nbrjobs a, SPRIDEN, perhsim, ztrhsbc, PTRHSIL, ptrhsme, PERHSIP, PEBHSIN
WHERE (ztrhsbc_hsin_no = PEBHSIN_NO) And (PTRHSIL_CODE = PEBHSIN_HSIL_CODE) And (PERHSIP_HSIN_NO = PEBHSIN_NO)
and nbbposn_posn = a.nbrjobs_posn AND (FTVORGN_orgn_code = a.nbrjobs_orgn_code_ts
and ftvorgn_coas_code = 'C' and (to_char(ftvorgn_nchg_date,'DD-MON-YYYY') = '31-DEC-2099'))
and a.nbrjobs_pidm = pebempl_pidm and a.nbrjobs_effective_date in (select max(b.nbrjobs_effective_date)
FROM nbrjobs b where a.nbrjobs_posn = b.nbrjobs_posn and a.nbrjobs_pidm = b.nbrjobs_pidm and a.nbrjobs_pidm = b.nbrjobs_pidm)
and a.nbrjobs_pidm = spriden_pidm and (spriden_change_ind is NULL)
and spriden_entity_ind = 'P' and a.nbrjobs_posn = perhsip_posn
and (TO_CHAR(ztrhsbc_activity_date,'MM/DD/YYYY')) >= &nbidate
and (TO_CHAR(ztrhsbc_activity_date,'MM/DD/YYYY')) <= &neidate
and perhsim_hsme_code = ptrhsme_code and SPBPERS_PIDM = a.nbrjobs_PIDM AND a.nbrjobs_PIDM = PERHSIP_PIDM
and perhsim_pidm = spriden_pidm(+)
and perhsip_pidm = perhsim_pidm(+) GROUP BY spriden_id, spriden_last_name, spriden_first_name, spriden_mi,
PEBHSIN_INCIDENT_DATE, PEBHSIN_DESC, PEBHSIN_INCIDENT_DATE, lpad(PEBHSIN_NO,6,0), PERHSIP_OSHA_IND, PERHSIP_WORK_COMP_IND, perhsip_posn, a.nbrjobs_orgn_code_ts,
ftvorgn_title, ztrhsbc_activity_date, ztrhsbc_bwc_claim_no, perhsim_hsme_code, perhsim_begin_date, perhsim_end_date, perhsim_hours_lost, perhsim_hours_work_restricted, ptrhsme_desc, sysdate