MySQL: Creating regr_slope function -


in mysql have added function calculate slope:

delimiter $$ create function regr_slope(x float, y float) returns float deterministic begin    declare n int;   declare sum_x float;   declare sum_y float;   declare sum_xx float;   declare sum_xy float;   declare slope float;    set n = count(x);   set sum_x = sum(x);   set sum_y = sum(y);   set sum_xx = sum(x*x);   set sum_xy = sum(x*y);    set slope = (n * sum_xy - sum_x * sum_y) / (n * sum_xx - power(sum_x, 2));    return slope; end$$ delimiter ; 

however, when use this:

select regr_slope(pd.avg_velocity, pd.load_kg) push_data 

i error invalid use of group function. reason this?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -