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

x
?
Solved

Help with REGR_SLOPE function

Posted on 2013-01-22
4
Medium Priority
?
1,104 Views
Last Modified: 2013-01-27
I am trying to use the REGR_SLOPE function, but I am getting null values back from the function. I am probably making a simple mistake, but could do with some help understanding where I am going wrong:

SQL> select * from test_slope;

   SL_AGE    SL_MEAN
---------- ----------
         0      56.67
        20     292.33
        40        548
        60        713
        80     943.67

SQL> select sl_age, sl_mean, regr_slope(sl_age, sl_mean) 
over (partition by sl_age) "SLOPE" from test_slope;

   SL_AGE    SL_MEAN      SLOPE
---------- ---------- ----------
         0      56.67 
        20     292.33 
        40        548 
        60        713 
        80     943.67 

 

Open in new window


I am expecting to get the following SLOPE values:

 SL_AGE    SL_MEAN      SLOPE
---------- ---------- ----------
         0      56.67       
        20     292.33      11.78
        40        548      12.28
        60        713      11.12
        80     943.67      10.97

Open in new window

0
Comment
Question by:theskintman
  • 3
4 Comments
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 38805056
check the below one..

select sl_age, sl_mean, regr_slope(100-sl_age, sl_mean)
over (partition by sl_age) "SLOPE" from test_slope;
0
 

Author Comment

by:theskintman
ID: 38805073
That produces the same NULL outcome. What is your logic to doing "100-sl_age"?
0
 

Accepted Solution

by:
theskintman earned 0 total points
ID: 38805288
Solved:
select sl_age, sl_mean, regr_slope(sl_mean, sl_age) over (order by sl_age) "SLOPE" from test_slope;

Open in new window

0
 

Author Closing Comment

by:theskintman
ID: 38823769
I eventually worked it out for myself.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
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.
Suggested Courses

971 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