Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery - combine tables

I have monthly Data in BigQuery but I want to create a yearly database, meaning combine the 12 subdatabase to 1.

How can it be done?

The structure is identical for all 12 databases in form:

Date, Name, Amount, Value, Type_of_Good

I thought JOIN might help me, but it is not the case.

Thanks

like image 559
Ilja Avatar asked Jan 11 '15 11:01

Ilja


People also ask

How do I append one table to another in BigQuery?

To append to or overwrite a table using query results, specify a destination table and set the write disposition to either: Append to table — Appends the query results to an existing table. Overwrite table — Overwrites an existing table with the same name using the query results.

Does BigQuery support merge?

You can implement the Merge query to perform the update, upsert, and delete operations on a Google BigQuery target in a single SQL statement.

How do I combine two columns in BigQuery?

The BigQuery CONCAT function allows you to combine (concatenate) one more values into a single result. Alternatively, you can use the concatenation operator || to achieve the same output.


1 Answers

you can use the following syntax

SELECT Date, Name, Amount, Value, Type_of_Good
FROM
(select Date, Name, Amount, Value, Type_of_Good from january ...),
(select Date, Name, Amount, Value, Type_of_Good from february ...),
...
(select Date, Name, Amount, Value, Type_of_Good from december ...)
like image 68
Pentium10 Avatar answered Oct 19 '22 05:10

Pentium10