集計関数
1分以内
集計関数
Group By
SubQuery は高度な集約関数をサポートしており、クエリ中に一連の値に対して計算を実行することができます。
集計関数は通常、クエリの GroupBy 関数で使用されます。
GroupBy を使用すると、1 つのクエリで SubQuery から異なる値をすばやく取得できます。
高度な集計関数
SubQuery は unsafe モードの場合に以下の集約関数を提供します。
sum
(数値のようなフィールドに適用) - すべての値を足した結果distinctCount
(すべてのフィールドに適用) - 異なる値の数をカウントします。min
(数値のようなフィールドに適用) - 最小の値max
(数値のようなフィールドに適用) - 最大値average
(数値のようなフィールドに適用) - 平均 (算術平均) 値stddevSample
(数値のようなフィールドに適用) - 値の標準偏差のサンプルstddevPopulation
(数値のようなフィールドに適用) - 値の母集団標準偏差varianceSample
(数値のようなフィールドに適用) - 値の分散のサンプルvariancePopulation
(数値のようなフィールドに適用) - 値の母分散
SubQuery's implementation of aggregate functions is based on pg-aggregates, you can find more information there.
Important Please note that you must enable the `--unsafe` flag on the query service in order to use these functions. [Read more](./references.md#unsafe-query-service).
Also, note that the --unsafe
command will prevent your project from being run in the SubQuery Network, and you must contact support if you want this command to be run with your project in SubQuery's managed service. :::