Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> find the last date of between two months ranges
Hi,
I need to find the last days of the transaction that is between 20 to 30 months old and then sum the amount total. I try to do the following:
select a.transaction_id, sum(amount)
from my_table a,
(select transaction_id, max(transaction_date) max_date from my_table\ group by transaction_id) b where a.transaction_id = b.transaction_id and months_between(sysdate, b.max_date) between 20 and 30)group by a.transaction_id
This is quite awkward. Please let me know of any better solutions.
Thanks in advance.
Nick Li Received on Wed May 11 2005 - 19:20:44 CDT