?
Solved

using RECURSIVE WITH statement - using oracle 11g

Posted on 2012-12-28
4
Medium Priority
?
374 Views
Last Modified: 2012-12-28
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
0
Comment
Question by:PHIL Sawyer
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 38727132
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
 

Author Comment

by:PHIL Sawyer
ID: 38727240
Hello
This one works if I change t.date, -11 to
t.date, -12

Many thanks again
0
 

Author Closing Comment

by:PHIL Sawyer
ID: 38727344
Thanks
0
 
LVL 32

Expert Comment

by:awking00
ID: 38727383
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question