BaşlayınÜcretsiz Başlayın

Satır tabanlı WINDOW fonksiyonlarını kullanma

Window fonksiyonları genellikle satır tabanlı bir pencere alır; mevcut satırdan önceki veya sonraki belirli sayıda satıra bakar. Bu egzersizde, aynı sorguyu üç kez kullanarak satır tabanlı bir window fonksiyonu oluşturacaksın.

Bu egzersiz

BigQuery'ye Giriş

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

-- 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;
Kodu Düzenle ve Çalıştır