SQL BigQuery 行到列
SQL BigQuery Rows to column
这是我的数据样本
我正在尝试获取:
谢谢
您可以使用 unnest()
和数组在 BigQuery 中逆透视:
select t.holiday, t.segment, el.dte, el.booking
from t cross join
unnest(array[struct('1/1/2020' as dte, "1/1/2020" as booking),
struct('1/2/2020' as dte, "1/2/2020" as booking),
. . .
]
) el;
这是我的数据样本
我正在尝试获取:
谢谢
您可以使用 unnest()
和数组在 BigQuery 中逆透视:
select t.holiday, t.segment, el.dte, el.booking
from t cross join
unnest(array[struct('1/1/2020' as dte, "1/1/2020" as booking),
struct('1/2/2020' as dte, "1/2/2020" as booking),
. . .
]
) el;