शुरू करेंमुफ़्त में शुरू करें

ROW आधारित WINDOW फंक्शन का उपयोग

Window फंक्शन अक्सर पंक्तियों पर आधारित विंडो लेते हैं, जहाँ वे मौजूदा पंक्ति से पहले या बाद की कुछ पंक्तियों को देखते हैं। इस अभ्यास में, आप एक ही क्वेरी को तीन बार उपयोग करके row-based window फंक्शन बनाएँगे।

यह अभ्यास पाठ्यक्रम का हिस्सा है

BigQuery परिचय

पाठ्यक्रम देखें

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

-- Complete the query to find the rolling average

SELECT
  order_id,
  order_purchase_timestamp,
  -- Aggregate the price to find the average item price
  AVG(___) 
  OVER(
    -- Order the query by the purchase timestamp
    ORDER BY ___ 
    -- Start the rows window as a between statement
    ROWS ___
    -- Create the window for the nine previous rows
    ___ ___
    -- Stop the window at the current row
    AND ___ ROW) as rolling_avg
FROM ecommerce.ecomm_order_details od
JOIN ecommerce.ecomm_orders o 
USING (order_id), unnest(o.order_items) as item
ORDER BY order_purchase_timestamp;
कोड संपादित करें और चलाएँ