BIG QUERY 中的数据透视为具有 space 的行数据提供错误。字段必须仅包含字母数字下划线以字母或下划线开头

Pivot in BIG QUERY giving error for row data having a space . Fields must contain only letters numbers underscores start with a letter or underscore

我正在尝试使用以下查询在大查询中执行 PIVOTING

select * from
(SELECT desc,qty,RSN_DESC FROM `TABLE`)
  PIVOT(SUM(qty) FOR RSN_DESC IN ('Example1', 'Example2', 'Example3', 'Example 3','Example4','Example 5',''))

如果您仔细观察“示例 3”和“示例 5”,我们在数据之间有一个 space,例如“Store Ops”(我的数据中的一个实际示例)。 Pivot 不适用于此类数据,它会给出错误

Invalid field name "Store Ops". Fields must contain only letters, numbers, and underscores, start with a letter or underscore, and be at most 300 characters long.

关于如何处理这种情况有什么建议吗?

改用下面的方法

select * from
(SELECT `desc`,qty,RSN_DESC FROM `TABLE`)
PIVOT(SUM(qty) FOR replace(RSN_DESC, ' ', '_') IN ('Example1', 'Example2', 'Example3', 'Example_3','Example4','Example_5',''))    

在这种情况下 'Example3'、'Example_3' 将是不同的列

select * from
(SELECT `desc`,qty,RSN_DESC FROM `TABLE`)
PIVOT(SUM(qty) FOR replace(RSN_DESC, ' ', '') IN ('Example1', 'Example2', 'Example3', 'Example4','Example5',''))    

在这种情况下,'Example3' 和 'Example 3' 将折叠成一列