[英]In BigQuery how do I total fields that match the same date and id?
I have some data in BigQuery that is 3 columns: date, id, quantity.我在 BigQuery 中有一些数据是 3 列:日期、ID、数量。 Example:例子:
2021-2-2 | abcd | 123
2021-2-2 | abcd | 456
2021-2-1 | efgh | 321
2021-2-1 | efgh | 654
I'd like to combine and total where the dates and ids match like so:我想组合和总计日期和 id 匹配的位置,如下所示:
2021-2-2 | abcd | 579
2021-2-1 | efgh | 975
I think the best way to go about this would be to put all of the new data into a new BigQuery table, then delete the old.我认为 go 的最佳方法是将所有新数据放入一个新的 BigQuery 表中,然后删除旧的。 How would I go about running the query and writing to a new table for a large data set using a Node Cloud Function?我将如何 go 使用节点云 Function 运行查询并写入大型数据集的新表?
If I understand correctly, you just want group by
:如果我理解正确,您只需要group by
:
select date, id, sum(quantity)
from t
group by date, id;
If this answers your question, you should make some effort to learn SQL -- there are many tutorials, books, and online resources that can help.如果这回答了您的问题,您应该努力学习 SQL - 有许多教程、书籍和在线资源可以提供帮助。 GROUP BY
is very basic SQL and some background in the language will help you use BigQuery. GROUP BY
是非常基本的 SQL,一些语言背景将帮助您使用 BigQuery。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.