RIGHT、LEFT 與 OUTER 連接
雖然 INNER JOIN 是最常用的連接方式之一,但有時你也需要包含不符合連接條件的資料,來自連接中的其中一個或兩個資料表。這個練習會帶你走過 BigQuery 中各種連接類型,以及如何使用它們。
本練習屬於課程
BigQuery 入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
WITH orders AS (
SELECT order_id, item.product_id
FROM ecommerce.ecomm_orders, UNNEST(order_items) item
LIMIT 10
),
products AS (
SELECT product_id
FROM ecommerce.ecomm_products
LIMIT 10000
)
SELECT
COUNT(*) AS orders
FROM orders o
-- Add the correct join to include all the values from the "orders" table
___ products p ON p.product_id = o.product_id;