I have 2 tables with a large number of records (100k+).
Table B is the base that i have extracted and need to join to table B.
I have to pull invoices for records for the previous 3 months. Where i am getting lost is on how to account for pulling records for the previous year if the date i have is for Jan.
I need to pull records where bill month falls in the 3 months before the sus month. Meaning 3 records.
I have tried this but get no records... and i realize that it won't help me if the Sus_month value is 1 . The months being from 1 - 12.
and I have no idea on how to account for cases where it will need to pull from 2018
PROC SQL;
CONNECT TO ORACLE (USER=&NAME PW=&PASS PATH=EXAODIN);
CREATE TABLE CHARGE AS
SELECT B.*,A.* FROM CONNECTION TO ORACLE
(SELECT ID,SUB,BILL_YEAR,BILL_MONTH
FROM OS.CHARGE
) A INNER JOIN TEST2 B
ON B.ID= A.ID
WHERE A.BILL_MONTH BETWEEN (B.SUS_MONTH -3) AND (B.SUS_MONTH -1)
;
DISCONNECT FROM ORACLE;
QUIT;