我花了一些时间在 BigQuery 上做了一个 - 我认为 - 简单的动态透视(列将动态添加),但我可以找到解决方案。 我尝试过的一些教程:
1 号的人也有同样的错误按摩,但无法找到解决方案。 我的一段代码如下:
`declare dec string;
set dec = (
select
string_agg (distinct concat("'",extract (year from date1), '-',
extract (month from date1), "'" )) as ref_active_cte
from` table
);
execute immediate
"""
with cte_block1 as (), -- does not really matter
cte_block2 as () -- -- does not really matter
select
*
from
(
select value, classes, year
)
pivot(sum(value) for classes in (?) )
"""
using dec`
我只需要一个简单的模板代码,我可以用它来制作动态枢轴,因为我将有很多个月或者可能是课程。 我想知道我的代码中做错了什么。