近似统计函数
GoogleSQL 提供了 4 个近似聚合函数,可在大型数据集上获得更好的性能:APPROX_COUNT_DISTINCT、APPROX_QUANTILES、APPROX_TOP_COUNT、APPROX_TOP_SUM。本练习将带您用每个函数分别完成同一条查询。
本练习是课程的一部分
BigQuery 入门
交互式实操练习
通过完成这段示例代码来试试这个练习。
-- Complete the query to approximate the number of customers that have ordered each product
SELECT
items.product_id,
-- Add the correct syntax for the approximate distinct count
___ AS estimated_unique_customers
FROM ecommerce.ecomm_orders o, UNNEST(o.order_items) items
JOIN ecommerce.ecomm_order_details od USING (order_id)
GROUP BY items.product_id;