在查询中创建数组
在聚合数据时,您有时仍然希望保留部分原始数据,使用 ARRAY 是很好的做法。例如,在本练习中,您将通过编写子查询来创建一个新的 ARRAY。
本练习是课程的一部分
BigQuery 入门
练习说明
- 为重量为 2,220 克的商品创建由
product_id组成的数组。首先,请查看ecomm_products表,确认存储重量信息的列。
交互式实操练习
通过完成这段示例代码来试试这个练习。
-- Fill in the query to construct the array
SELECT
ARRAY(SELECT
-- Add the column with the values you want in the array
___
FROM
ecommerce.ecomm_products
WHERE
-- Add the column we want to filter by
___ = 2220)