agg 聚合函数

适用于:检查标记为“是”的 Databricks SQL 检查标记为“是”的 Databricks Runtime 18.1 及更高版本

返回从组值中汇总的measure_column。 此函数是聚合函数的measure同义词。

与类似 measureagg 不指定聚合本身。 它从 指标视图定义继承聚合的定义。

Syntax

agg ( measure_column )

不能使用子句将此OVER调用。

参数

退货

某种类型的值 measure_column

示例

以下示例假定指标视图 region_sales_metrics 具有 total_revenue_per_customer 度量值。 有关完整的指标视图定义,请参阅 measure 聚合函数

-- Tracking total_revenue_per_customer by month in 1995
> SELECT extract(month from month) as month,
    agg(total_revenue_per_customer)::bigint AS total_revenue_per_customer
  FROM region_sales_metrics
  WHERE extract(year FROM month) = 1995
  GROUP BY ALL
  ORDER BY ALL;
  month  total_revenue_per_customer
  -----  --------------------------
   1     167727
   2     166237
   3     167349