我有一个从Shopify导出的BigQuery数据集,我已经将数据集的范围缩小到某个日期范围内的订单号,该订单号包含订单号和一个实现对象数组。我现在需要找回跟踪号和订单号的列表。
[
{
"order_number": "5545",
"fulfillments": [
{
"tracking_url": null,
"id": "617029074993",
"tracking_company": "ups",
"tracking_number": "Z1234567890"
},
{
"tracking_url": null,
"id": "617029075334",
"tracking_company": "ups",
"tracking_number": "Z1234988901"
},
{
"tracking_url": null,
"id": "617029036534",
"tracking_company": "ups",
"tracking_number": "Z1234987801"
}
],
"_sdc_batched_at": "2018-11-10 02:46:24.270 UTC",
"_sdc_sequence": "1541817507934"
},
{
"order_number": "2214",
"fulfillments": [
{
"tracking_url": null,
"id": "617029223993",
"tracking_company": "ups",
"tracking_number": "Z1234456890"
},
{
"tracking_url": null,
"id": "617024455334",
"tracking_company": "ups",
"tracking_number": "Z1234780901"
}
],
"_sdc_batched_at": "2018-11-10 02:46:21.270 UTC",
"_sdc_sequence": "1541817545934"
}
]
每行都是订单号和跟踪号的组合
[
{
"order_number": "5545",
"tracking_number": "Z1234567890"
},
{
"order_number": "5545",
"tracking_number": "Z1234988901"
},
{
"order_number": "5545",
"tracking_number": "Z1234987801"
},
{
"order_number": "2214",
"tracking_number": "Z1234456890"
},
{
"order_number": "2214",
"tracking_number": "Z1234780901"
}
]
答案 0 :(得分:2)
以下是用于BigQuery标准SQL
#standardSQL
SELECT order_number, fulfillment.tracking_number
FROM `project.dataset.table`,
UNNEST(fulfillments) fulfillment