QUALIFY ile filtreleme
Bir pencere fonksiyonunun sonucunu WHERE filtresi gibi kullanman gerektiğinde QUALIFY kullanmalısın. Bu sorguda, mevcut satır ve önceki 9 satırın hareketli ortalamasının 500'ün üzerinde olduğu tüm zamanları bulacaksın.
Bu egzersiz
BigQuery'ye Giriş
kursunun bir parçasıdırEgzersiz talimatları
- Sorguyu, pencere fonksiyonunu ve sorguyu filtrelemek için
QUALIFYifadesini doldurarak tamamla.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
-- Complete the query to find all times when the rolling average is over $500
SELECT
order_id,
order_purchase_timestamp,
-- Complete the rolling average for the current and nine previous rows
AVG(___)
OVER(ORDER BY ___
ROWS BETWEEN ___ ___ 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
-- Add the qualify statement to find all rows with an average over $500
QUALIFY ___ ___
ORDER BY order_purchase_timestamp;