Birden fazla CTE kullanma
Birden fazla CTE kullanmak, kodun performansını ve okunabilirliğini ciddi ölçüde artırabilir. Bu örnekte, bir sorguyu iki CTE'ye bölerek hem okumayı kolaylaştıracak hem de performansı yükselteceksin.
Bu egzersiz
BigQuery'ye Giriş
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
-- Create a CTE named "orders" that handles the queries for the ecomm_orders table
WITH orders AS (
SELECT ___, items.___, items.___
FROM ecommerce.ecomm_orders, UNNEST(___) items
WHERE items.price > ___
)
SELECT
order_id,
AVG(p.product_weight_g) as avg_weight
FROM orders o
JOIN ecommerce.ecomm_products p ON o.product_id = p.product_id
GROUP BY o.order_id;