Solved

Find REGR_SLOPE with dates?

Posted on 2008-10-01
3
1,088 Views
Last Modified: 2013-12-07
How can I use REGR_SLOPE with dates? I know it only takes numbers as input, but I would like find the REGR_SLOPE as a function of time.  My table is as follows:

Table
--------------------
Num | Date
1      | 10-JAN-07
3      | 30-JAN-07
7      | 11-FEB-07
5      | 13-FEB-07
5      | 19-FEB-07
3      | 03-MAR-07

I only need a 90 day range if that makes a difference.
0
Comment
Question by:evotsi
3 Comments
 
LVL 27

Expert Comment

by:sujith80
ID: 22617116
You are trying to find the REGR_SLOPE of which column? Aggregated at which column?
0
 

Author Comment

by:evotsi
ID: 22617348
I am trying to find the REGR_SLOPE of the 'Num' column across a timespan.  For example the table could also be seen as:

Table
--------------------
Num | Date
1      | 1
3      | 30
7      | 42
5      | 44
5      | 50
3      | 62

In which case I believe REGR_SLOPE(Date,Num) would get me what I want.
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 22651977
to treat your dates as numbers, convert them to their Julian value

SELECT   regr_slope(to_number(to_char(yourdate,'j')),num)
  FROM   yourtable
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

777 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