简体   繁体   English

UNNEST 和加入 | 大查询

[英]UNNEST and JOIN | Big Query

I'm able to unnest one table in Big Query by using the following code:我可以使用以下代码在 Big Query 中取消嵌套一个表:

SELECT * EXCEPT(instance, line_items) FROM (
SELECT *, ROW_NUMBER() OVER(PARTITION BY id) AS instance
  FROM `shopify.orders`
), UNNEST(line_items) as item

WHERE instance = 1 WHERE 实例 = 1

Additionally, I'm able to JOIN this table (unnested) with another table using the following code:此外,我可以使用以下代码将此表(未嵌套)与另一个表连接起来:

SELECT * FROM (
  SELECT *, ROW_NUMBER() OVER(PARTITION BY id) AS instance
  FROM `shopify.orders`
  JOIN `google_analytics.GA`
  ON name = TransactionID

)

WHERE instance = 1

However, I'm not sure how to JOIN these two tables while still unnesting the values from my first query.但是,我不确定如何加入这两个表,同时仍然从我的第一个查询中取消嵌套值。 Any idea of how I can join an UNNESTED table with another table?知道如何将 UNNESTED 表与另一个表连接起来吗?

Doesn't join work? join不行吗?

SELECT * EXCEPT(instance, line_items)
FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY id) AS instance
      FROM `shopify.orders`
     ) o CROSS JOIN
     UNNEST(o.line_items) as item JOIN
     `google_analytics.GA` ga
      ON name = TransactionID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM