Try this code, the problem with this query is, it scans the table action_quantities twice.
Code:SELECT * FROM action_quantities a, ( SELECT MAX(Action_Date) act_dt FROM action_quantities a, ( SELECT to_date('&d1', 'DD-MON-YYYY') + (rownum - 1) dt FROM dual CONNECT BY LEVEL < (to_date('&d2', 'DD-MON-YYYY') - to_date('&d1', 'DD-MON-YYYY')+1) ) b WHERE trunc(a.action_date) = b.dt GROUP BY trunc(action_date) )b WHERE a.action_date = b.act_dt




Reply With Quote