集計関数 (Entity Framework 用 SqlClient)

.NET Framework Data Provider for SQL Server (SqlClient) には、集計関数が用意されています。 集計関数は、一連の入力値に対して計算を実行し、値を返します。 これらの関数は、SqlClient の SqlServer 名前空間に存在します。 Entity Framework は、プロバイダーの名前空間プロパティを使用することにより、型や関数など、特定のコンストラクターに対してこのプロバイダーによってどのプレフィックスが使用されているかを特定できます。

以下は、SqlClient の集計関数です。

AVG(expression)

コレクション内の値の平均値を返します。 NULL 値は無視されます。

引数

Int32Int64Double、および Decimal

戻り値

expression の型。

SELECT VALUE SqlServer.AVG(p.ListPrice) 
FROM AdventureWorksEntities.Products AS p 

CHECKSUM_AGG(collection)

コレクション内にある値のチェックサムを返します。 NULL 値は無視されます。

引数

Collection(Int32)。

戻り値

Int32

SELECT VALUE SqlServer.Checksum_Agg(cast(product.ListPrice AS Int32)) 
FROM AdventureWorksEntities.Products AS product 
WHERE product.ListPrice > cast(@price AS Decimal) 

COUNT(expression)

コレクション内のアイテムの数を Int32 型の値として返します。

引数

Collection<T>。T は次のいずれかの型です。

  • Boolean
  • Double
  • DateTime
  • DateTimeOffset
  • Time
  • String
  • Binary
  • Guid (SQL Server 2000 では返されません)

戻り値

Int32

ANYELEMENT(SELECT VALUE SqlServer.COUNT(product.ProductID) 
FROM AdventureWorksEntities.Products AS product 
WHERE SqlServer.CEILING(product.ListPrice) == 
SqlServer.FLOOR(product.ListPrice)) 

COUNT_BIG(expression)

コレクション内のアイテムの数を bigint 型の値として返します。

引数

Collection(T)。T は次のいずれかの型です。

  • Boolean
  • Double
  • DateTime
  • DateTimeOffset
  • Time
  • String
  • Binary
  • Guid (SQL Server 2000 では返されません)

戻り値

Int64

ANYELEMENT(SELECT VALUE SqlServer.COUNT_BIG(product.ProductID) 
FROM AdventureWorksEntities.Products AS product 
WHERE SqlServer.CEILING(product.ListPrice) == 
SqlServer.FLOOR(product.ListPrice)) 

MAX(expression)

コレクション内の最大値を返します。

引数

Collection(T)。T は次のいずれかの型です。

  • Boolean
  • Double
  • DateTime
  • DateTimeOffset
  • Time
  • String
  • Binary

戻り値

expression の型。

SELECT VALUE SqlServer.MAX(p.ListPrice) 
FROM AdventureWorksEntities.Products AS p

MIN(expression)

コレクション内の最小値を返します。

引数

Collection(T)。T は次のいずれかの型です。

  • Boolean
  • Double
  • DateTime
  • DateTimeOffset
  • Time
  • String
  • Binary

戻り値

expression の型。

SELECT VALUE SqlServer.MIN(p.ListPrice) 
FROM AdventureWorksEntities.Products AS p

STDEV(expression)

指定された式のすべての値の統計的標準偏差を返します。

引数

Collection(Double)。

戻り値

Double

SELECT VALUE SqlServer.STDEV(product.ListPrice) 
FROM AdventureWorksEntities.Products AS product 
WHERE product.ListPrice > cast(@price AS Decimal) 

STDEVP(expression)

指定された式のすべての値を母集団として統計的標準偏差を返します。

引数

Collection(Double)。

戻り値

Double

SELECT VALUE SqlServer.STDEVP(product.ListPrice) 
FROM AdventureWorksEntities.Products AS product 
WHERE product.ListPrice > cast(@price AS Decimal) 

SUM(expression)

コレクション内のすべての値の合計を返します。

引数

Collection(T)。T は次のいずれかの型です: Int32Int64DoubleDecimal

戻り値

expression の型。

SELECT VALUE SqlServer.SUM(p.ListPrice) 
FROM AdventureWorksEntities.Products AS p

VAR(expression)

指定された式のすべての値の統計的分散を返します。

引数

Collection(Double)。

戻り値

Double

SELECT VALUE SqlServer.VAR(product.ListPrice) 
FROM AdventureWorksEntities.Products AS product 
WHERE product.ListPrice > cast(@price AS Decimal) 

VARP(expression)

指定した式のすべての値について、母集団に対する統計的変位を返します。

引数

Collection(Double)。

戻り値

Double

SELECT VALUE SqlServer.VARP(product.ListPrice) 
FROM AdventureWorksEntities.Products AS product 
WHERE product.ListPrice > cast(@price AS Decimal) 

関連項目