近似統計函式
GoogleSQL 提供四種近似彙總函式,可在大型資料集上取得更佳效能: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;