Solved

Help with REGR_SLOPE function

Posted on 2013-01-22
4
967 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 20

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
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, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

760 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

22 Experts available now in Live!

Get 1:1 Help Now