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:
I am expecting to get the following SLOPE values:
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
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
ASKER
That produces the same NULL outcome. What is your logic to doing "100-sl_age"?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I eventually worked it out for myself.
select sl_age, sl_mean, regr_slope(100-sl_age, sl_mean)
over (partition by sl_age) "SLOPE" from test_slope;