Solved

using RECURSIVE WITH statement - using oracle 11g

Posted on 2012-12-28
4
367 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 142

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 31

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now