I am joining the table to the view thru a claim number. If I left join and just put in the claim numbers from both tables, I get the claim table rows but not the view rows. I know the claim numbers are in there because I have checked. The view is building stauts for each claim thru periods of claim lifespan.
SELECT p.claim claim, d.dt dt, p.status currstatus, LAG (p.status, 1, NULL) OVER (PARTITION BY p.claim ORDER BY d.dt) prevmstatus, month_end, CASE WHEN d.quarter_end = 'Y' THEN LAG (p.status, 3, NULL) OVER (PARTITION BY p.claim ORDER BY d.dt) ELSE NULL END prevqstatus, quarter_end, CASE WHEN d.semi_end = 'Y' THEN LAG (p.status, 6, NULL) OVER (PARTITION BY p.claim ORDER BY d.dt) ELSE NULL END prevsstatus, semi_end, CASE WHEN d.annual_end = 'Y' THEN LAG (p.status, 12, NULL) OVER (PARTITION BY p.claim ORDER BY d.dt) ELSE NULL END prevastatus, annual_end FROM rptdate d, KEMpval p WHERE d.dt BETWEEN p.trans_dt AND NVL (p.next_trans_dt - 1, '01-JAN-2100') AND d.month_end = 'Y' AND d.dt <= TO_DATE ( '31-' || 'dec-' || TO_CHAR (ADD_MONTHS (SYSDATE, 12), 'yyyy') )