Solved

Find REGR_SLOPE with dates?

Posted on 2008-10-01
3
1,074 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
Comment Utility
You are trying to find the REGR_SLOPE of which column? Aggregated at which column?
0
 

Author Comment

by:evotsi
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

'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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 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

17 Experts available now in Live!

Get 1:1 Help Now