sam123
sam123

Reputation: 119

Join multiple tables in Bigquery

I have over 100 tables in my BQ, but i would like to create a single table with all the tables.

How is this possible? Now i am using the below query to export data manually by table.

SELECT 
date as Date,
SUM(totals.visits) as TotalVisits
From
[1243.ga_sessions_20160425]
Group by date
order by date

I also would like to add alias to each table so that i would know from which table the data came from.

please let me know thanks

Upvotes: 1

Views: 827

Answers (1)

N.N.
N.N.

Reputation: 3172

The way to union tables in BQ is by using table wildcard functions. your query should look something like: (If you share your data-set, we can verify the suggested query)

SELECT 
    date as Date,
    SUM(totals.visits) as TotalVisits
    From
    TABLE_QUERY(1243,'table_id contains"ga_sessions_"')
    Group by date
    order by date

Upvotes: 1

Related Questions