Don't touch my junk.

0

Please login or register to vote for this query.

(click on this box to dismiss)

English Language Learners

Q&A for speakers of other languages learning English

CREATE TABLE #Numbers 
( 
  Number DECIMAL(10,4),
  Variance DECIMAL(10,4),
  VarFloat Float
);
GO
INSERT INTO #Numbers (Number) VALUES
    (23),
    (37),
    (45),
    (49),
    (56),
    (63),
    (63),
    (70),
    (72),
    (82);
GO

DECLARE @Mean DECIMAL(10,4);
SET @Mean = (SELECT SUM (Number) / COUNT(Number) FROM #Numbers);
-- @Mean is 100
UPDATE #Numbers 
SET Variance = POWER( (@Mean - Number), 2),
    VarFloat = Power( (Number * 1.0 - @Mean), 2);
DECLARE @StdVariance DECIMAL(10,4);
SET @StdVariance = (SELECT SQRT( SUM(VarFloat) / COUNT(Number) ) FROM #Numbers);
SELECT 
  @Mean AS [Mean],
  @StdVariance AS [Standard Variance],
  Sum(Number) as [Sum],
  count(Number) as [Count],
  sum ((Number - @Mean) * (Number - @Mean)) as [SumVar],
  Avg(Number) as [Avg],
  StDev(Number) as [StdDev],
  StDevp(Number) as [StdDevP]
from #Numbers where Number = -1

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results