I am completely new to bq, i have a question, regarding MATH functions. Suppose i have a table called tab1 with A, B, C three cols. I want to write a query by which C’s values are replaced by the SUM(A+B) or A*B or something in a row-by-row basis. That means if the values of A = 2, B = 3 for the 1st row then C will be 5 and if the same is A = 4, B = 3 then C = 7 for the second row and so on.
I am just wondering if that is possible by writing one single query rather than visiting each row one by one and manually updating the values of C?
aiming to something like
UPDATE tab1 SET C = A+B
OR
UPDATE tab1 SET C = SUM(A,B)
Am I right in the thought process, is it possible?
BigQuery tables are append-only, so you can’t run
UPDATEqueries.However, you could run a query like this:
Result:
and then save that result to a new table, or export it as a CSV file into Google Cloud Storage.
Read about appending data to BigQuery tables, or saving a query result to a persistent table.