using RECURSIVE WITH statement - using oracle 11g

Hello
Another question similar to one posted earlier today - angelIII helped me out earlier but this one is slightly different and best explained by seeing the attached - see cell C108 as for the required answer.

I have a table with 2 columns date and amount - again see attached for required outcome.

Regards
recursive2.xls
PHIL SawyerAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the idea is again the same...
you join the row with the row from a date 12 months ago (months_add.. -11)
select max(delta)
  from ( select ( t.value - p.value ) / p.value delta
            from yourtable t
            join yourtable p
              on p.date = months_add(t.date, -11)
   )

Open in new window

0
 
PHIL SawyerAuthor Commented:
Hello
This one works if I change t.date, -11 to
t.date, -12

Many thanks again
0
 
PHIL SawyerAuthor Commented:
Thanks
0
 
awking00Commented:
Not sure but I'm thinking that, in order to match your spreadsheet line for line the join should be on add_months(p.date,-1) = add_months(t.date,-12)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.