?
Solved

Find REGR_SLOPE with dates?

Posted on 2008-10-01
3
Medium Priority
?
1,153 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
[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
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 74

Accepted Solution

by:
sdstuber earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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 recover a database from a user managed backup

719 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