January 4, 2011 at 4:34 am
hi friends,
I am just wondering if some one knows the way to find out SLOPE using T-SQL script. It is function in Excel but dont know if we can do something similar using T-SQL. The link below explains how it works for Excel.
http://support.microsoft.com/kb/828142
I tried few bits without luck.
Can any one help?
Thanks.
January 4, 2011 at 5:01 am
I got the solutions....
-- Create a test table
CREATE TABLE [TESTSTATS]( intKey INT, x FLOAT, y FLOAT)
-- Populate the test table with random data
DECLARE @intCount INT
SET @intCount = 1
WHILE @intCount < 11
BEGIN
INSERT INTO [TESTSTATS]
SELECT @intCount, @intCount, 5.12 * @intCount + 7 * rand()
SET @intCount = @intCount + 1
END
--– Get the Slope
SELECT (count(x)*sum(x*y) - sum(x)* sum(y))/(count(x)*sum(x*x) - sum(x)* sum(x))
FROM [TESTSTATS]
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy