I am trying to create a command for a union of two tables.
Without the Where clauses it works but it takes forever to process a reports because there are over a millions records in each table. I left out the names of the tables for privacy.
Any ideas or alternatives?
SELECT SCAN_CREATE_TM,
SCAN_CREATE_DT,
Null as PROCESS_IORG_NBR,
SCAN_IORG_NBR,
Null as SCAN_TYPE_CODE,
USER_ID,
Null as SCAN_USER
FROM hidden
WHERE (SCAN_CREATE_DT>=SYSDATE AND SCAN_CREATE_DT<SYSDATE-7)
UNION ALL
SELECT SCAN_CREATE_TM,
SCAN_CREATE_DT,
PROCESS_IORG_NBR,
Null as SCAN_IORG_NMB,
SCAN_TYPE_CODE,
Null as USER_ID,
SCAN_USER
FROM hidden
WHERE SCAN_TYPE_CODE='I' AND SCAN_CREATE_DT>=SYSDATE AND SCAN_CREATE_DT<SYSDATE-7)