篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MS SQL简单聚合相关的知识,希望对你有一定的参考价值。
SELECT Count(1) as Count,
Sum(OrderQty) as [Sum],
Avg(OrderQty) as [Avg],
Min(OrderQty) as [Min],
Max(OrderQty) as [Max]
FROM Sales.SalesOrderDetail;
-- [Output]
-- Count Sum Avg Min Max
-- 121317 274914 2 1 44
-- Statistical Functions
SELECT
StDevP(OrderQty) as [StDevP],
StDev(OrderQty) as [StDev],
VarP(OrderQty) as [VarP],
Var(OrderQty) as [Var]
FROM Sales.SalesOrderDetail
-- StDevP StDev VarP Var
-- 2.491... 2.491... 6.206... 6.206...