Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> find the last date of between two months ranges

find the last date of between two months ranges

From: nickli <ningli2000_at_hotmail.com>
Date: 11 May 2005 17:20:44 -0700
Message-ID: <1115857244.137696.57550@o13g2000cwo.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US