mean, median, mode in SQL Server Reporting Services

后端 未结 3 1419
青春惊慌失措
青春惊慌失措 2020-12-12 04:43

Is it possible to calculate an mean, median, mode, standard deviation, etc. of a column of data?

In general, is it possible to do these sorts of math calculations i

3条回答
  •  臣服心动
    2020-12-12 05:03

    Here is how I'm getting Mode for Ages:

    Declare @Temp Table(Id Int Identity(1,1), Data Decimal(10,5))
    
    Insert into @Temp Select DATEDIFF (YY, EmployeeCustomTabFields.CustDOB, GETDATE()) -
    Case When (MONTH(EmployeeCustomTabFields.CustDOB)=MONTH(GETDATE()) AND DAY(EmployeeCustomTabFields.CustDOB) > DAY(GETDATE()) OR MONTH (EmployeeCustomTabFields.CustDOB) > MONTH (GETDATE()))
    Then 1 Else 0 End as Age
    From EM
    inner join EmployeeCustomTabFields on EmployeeCustomTabFields.Employee = EM.Employee
    Where EmployeeCustomTabFields.CustDepartment = '23 - Piping Design' and EM.Status = 'A' and EM.Type in ('A','B','C')
    
    Select Top 1 with ties DATA
    From   @Temp
    Where  DATA IS Not NULL
    Group By DATA
    Order  By COUNT(*) DESC
    

提交回复
热议问题