Link to home
Start Free TrialLog in
Avatar of theskintman
theskintman

asked on

Help with REGR_SLOPE function

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

Avatar of Am P
Am P
Flag of India image

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;
Avatar of theskintman
theskintman

ASKER

That produces the same NULL outcome. What is your logic to doing "100-sl_age"?
ASKER CERTIFIED SOLUTION
Avatar of theskintman
theskintman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I eventually worked it out for myself.