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;