เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

ฟังก์ชันสถิติแบบประมาณค่า

GoogleSQL มีฟังก์ชัน aggregate แบบประมาณค่าสี่ตัวที่ให้ประสิทธิภาพดีกว่าเมื่อทำงานกับชุดข้อมูลขนาดใหญ่ ได้แก่ 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;
แก้ไขและรันโค้ด