複数のCTEを使う
複数のCTEを使うと、コードのパフォーマンスと可読性が大きく向上します。この演習では、読みやすく効率的にするために、1つのクエリを2つのCTEに分けて作成します。
この演習はコースの一部です
BigQuery入門
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
-- 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;