Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google bigquery 如何根据求和值创建包含总计的新列_Google Bigquery - Fatal编程技术网

Google bigquery 如何根据求和值创建包含总计的新列

Google bigquery 如何根据求和值创建包含总计的新列,google-bigquery,Google Bigquery,我在BigQuery中有一个类似的数据表 我期望的结果是: 我一直在尝试使用MAX(当国家='France'然后'yes'结束时的情况)作为法国来创建列,在这些列中,我可以识别客户是否在该国购买,但不能识别他们所有购买的数量。感谢您的帮助。请尝试: 或: countif解决方案非常有效。此时我无法测试pivot操作符,因为它返回了一个错误,表示字段名无效。真实数据包含空格,所以我需要先清理一下。非常感谢。 select customer, countif(Country='Franc

我在BigQuery中有一个类似的数据表

我期望的结果是:

我一直在尝试使用
MAX(当国家='France'然后'yes'结束时的情况)
作为法国来创建列,在这些列中,我可以识别客户是否在该国购买,但不能识别他们所有购买的数量。感谢您的帮助。

请尝试:

或:


countif解决方案非常有效。此时我无法测试pivot操作符,因为它返回了一个错误,表示字段名无效。真实数据包含空格,所以我需要先清理一下。非常感谢。
select
  customer,
  countif(Country='France') as France,
  countif(Country='UK') as UK,
  countif(Country='Ireland') as Ireland
from mytable
group by customer
SELECT *
FROM mytable
PIVOT(COUNT(TransactionId) FOR Country IN ('France', 'UK', 'Ireland'))