Solved

using RECURSIVE WITH statement - using oracle 11g

Posted on 2012-12-28
4
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
run sql script from putty 4 188
subtr returning incorrect value 8 68
format dd/mm/yyyy parameter 16 48
Oracle database T-1 Setup 7 27
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 post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
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.

733 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