Hi All,
I got a requirement to create a report that should extract past 15 months data from the database.
I have prepared the SQL script for reference.
SELECT TRUNC (table1.CREATE_DATE, 'MM'),
table1.state_code,
table2.detail,
COUNT ( * )
FROM table1, table2
WHERE table1.state_code = table2.state_cd
AND table1.CREATE_DATE >=
( SELECT TRUNC ( (ADD_MONTHS (SYSDATE, -15)), 'MM') FROM DUAL)
AND table1.CREATE_DATE <=
( SELECT LAST_DAY (ADD_MONTHS (SYSDATE, -1)) FROM DUAL)
GROUP BY TRUNC (table1.CREATE_DATE, 'MM'), table1.state_code, table2.detail
Is there anyother efficient way that I can achieve the same results.
Thanks in Advance!
Regards,
Ramya.