Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime 18.1 and above
Returns the measure_column aggregated from the values of a group. This function is a synonym for measure aggregate function.
Like measure, agg does not specify the aggregation itself. It inherits the definition of the aggregation from the metric view definition.
Syntax
agg ( measure_column )
This function cannot be invoked as a window function using the OVER clause.
Arguments
- measure_column: A reference to a measure column in a metric view.
Returns
A value of the type of measure_column.
Examples
The following example assumes a metric view region_sales_metrics with a total_revenue_per_customer measure. For the full metric view definition, see measure aggregate function.
-- 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