You are on page 1of 1

how do you do a union in sqr:

----------------------------hi
its working now, we need to select and assign values in pre union select stmt on
ly,
but i have another problem abt dttm
it is printing as dummy1
sql in sqr format is begin-SELECT
b.emplid &StrEmplid
let $StrEmplid = &StrEmplid
b.referral_dttm &referaldt
let $referaldt = &referaldt
b.hrs_person_id &hrspid
let $hrspid = &hrspid
a.status_code &status_code
let $status_code=&status_code
a.HRS_ROW_ADD_DTTM &HRS_ROW_ADD_DTTM
let $HRS_ROW_ADD_DTTM=&HRS_ROW_ADD_DTTM
a.HRS_ROW_ADD_OPRID &HRS_ROW_ADD_OPRID
let $HRS_ROW_ADD_OPRID=&HRS_ROW_ADD_OPRID
a.HRS_ROW_UPD_DTTM &HRS_ROW_UPD_DTTM
let $HRS_ROW_UPD_DTTM=&HRS_ROW_UPD_DTTM
a.HRS_ROW_UPD_OPRID &HRS_ROW_UPD_OPRID
let $HRS_ROW_UPD_OPRID=&HRS_ROW_UPD_OPRID
FROM PS_HRS_APPLICANT A, PS_HRS_EE_REFERRAL b
where b.appl_emplid=' '
AND A.HRS_PERSON_ID = B.HRS_PERSON_ID
AND A.HRS_PERSON_ID IN (SELECT hrs_person_id
FROM ps_hrs_rcmnt
WHERE ( TRUNC (hrs_row_add_dttm) BETWEEN &FrmDate
AND &ToDate
OR TRUNC (hrs_row_upd_dttm) BETWEEN &FrmDate
AND &ToDate
))
union select
b.emplid,
b.referral_dttm,
a.hrs_person_id,
a.status_code,
a.HRS_ROW_ADD_DTTM,
a.HRS_ROW_ADD_OPRID,
a.HRS_ROW_UPD_DTTM,
a.HRS_ROW_UPD_OPRID
from ps_hrs_rcmnt a,PS_HRS_EE_REFERRAL b
where b.appl_emplid=' '
AND A.HRS_PERSON_ID = b.HRS_PERSON_ID
AND a.HRS_PERSON_ID IN (SELECT hrs_person_id
FROM ps_hrs_rcmnt
WHERE ( TRUNC (hrs_row_add_dttm) BETWEEN &FrmDate
AND &ToDate
OR TRUNC (hrs_row_upd_dttm) BETWEEN &FrmDate
AND &ToDate
))
Thanks All
after puting commas in union select field1,field2
its working fine
Thanks

You might also like