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
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