66 Oracle資料庫SQL開發之 高階查詢——使用線性迴歸函式
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
66.Oracle資料庫SQL開發之 高階查詢——使用線性迴歸函式
歡迎轉載,轉載請標明出處:http://blog.csdn.net/notbaron/article/details/49847067
線性迴歸函式可以用普通最小平方迴歸曲線擬合一組數值對。線性迴歸函式可用於聚合、串列埠或報表函式。
如下圖1:
例如:
[email protected]> selectprd_type_id,regr_avgx(amount,month) as avgx,
regr_avgy(amount,month) as avgy,
regr_count(amount,month) as count,
regr_intercept(amount,month) as inter,
regr_r2(amount,month) as r2,
regr_slope(amount,month) as slope,
regr_sxx(amount,month) as sxx,
regr_sxy(amount,month) as sxy,
regr_syy(amount,month) as syy
fromall_sales
whereyear=2003 group by prd_type_id;
PRD_TYPE_ID AVGX AVGY COUNT INTER R2 SLOPE SXX SXY
----------- ---------- -------------------- ---------- ---------- ---------- ---------- ----------
SYY
----------
1 6.5 12570.5811 72 13318.4543 .003746289-115.05741 858 -98719.26
3031902717
2 6.5 2588.62806 72 2608.11268 .0000508 -2.997634 858 -2571.97
151767392
5 0
4 6.5 5593.76611 72 2043.47164 .128930297546.199149 858 468638.87
1985337488
3 6.5 6642.65153 72 2154.23119 .126338815690.526206 858 592471.485
3238253324