[英]How can i unnest a string field into rows in SQL BIGQUERY
how to unnest a string field Table Flags: id of type integer and categories of type string如何取消嵌套字符串字段表标志:类型为 integer 的 ID 和类型为字符串的类别
ID ![]() |
Categories![]() |
---|---|
1201 ![]() |
Uncategorized, Issues from Project Side, CI Configurations Issue![]() |
1202 ![]() |
Machine Stability, Machine Stability, Machine Stability,![]() |
Output needed需要Output
ID ![]() |
categories![]() |
---|---|
1201 ![]() |
Uncategorized![]() |
1201 ![]() |
Issues from project side![]() |
1201 ![]() |
CI Configurations Issue ![]() |
1202 ![]() |
Machine Stability![]() |
1202 ![]() |
Machine Stability![]() |
1202 ![]() |
Machine Stability![]() |
Thanks谢谢
select *,
(select ( categories)
from unnest(split(categories)) categories
)as distinct_product_count
FROM `Flags`
i got error Scalar subquery produced more than one element我得到错误标量子查询产生了不止一个元素
You don't need to use a subquery to do this, you are right to use split
within the unnest
function but you can specify it right after the from
clause like this:您不需要使用子查询来执行此操作,您可以在
unnest
function 中使用split
,但您可以在from
子句之后立即指定它,如下所示:
select
ID,
category
from `Flags`, unnest(split(categories)) as category
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.