correlation di sqlserver

duh duh duh..

dulu pas ngitung correlation ngitungnya pake PHP ,

sekarang karena env kalau bisa gak pake PHP, hanya sqlserver mau tidak mau suka tidak suka harus pake sqlserver deh

akhirnya nemu link menarik , dari link itu bisa dilihat query untuk menghitung correlation :

SELECT 
   (COUNT(*)*SUM(x.Sales*y.Sales)-SUM(x.Sales)*SUM(y.Sales))/(
   SQRT(COUNT(*)*SUM(SQUARE(x.Sales))-SQUARE(SUM(x.Sales)))*
   SQRT(COUNT(*)*SUM(SQUARE(y.Sales))-SQUARE(SUM(y.Sales)))) 
   correlation
FROM BulbSales x JOIN BulbSales y ON x.month=y.month
WHERE x.Year=1997 AND y.Year=1998 

have fun …. c o d i n g

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *