ComenzarEmpieza gratis

Using multiple CTEs

Using multiple CTEs can greatly improve the performance and legibility of code. In this example, you will split a query into two CTEs to make it easier to read and more performant.

Este ejercicio forma parte del curso

Introduction to BigQuery

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

-- 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;
Editar y ejecutar código