Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1190
  • Last Modified:

Find REGR_SLOPE with dates?

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
evotsi
Asked:
evotsi
1 Solution
 
sujith80Commented:
You are trying to find the REGR_SLOPE of which column? Aggregated at which column?
0
 
evotsiAuthor Commented:
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
 
sdstuberCommented:
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now