Solved

Help with REGR_SLOPE function

Posted on 2013-01-22
4
1,036 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
[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
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
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 shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

739 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