Skip to content
Advertisement

union all two table instead of join

I have several table which I can not join them as it gets really complicated and bigquery is not able to process it. So I am trying to union all tables and then group by. I have an issue during this process. I have two tables called t1 and t2 with below headers, they don’t have null values:

so in order to union all and group them I have below code:

unfortunately when I run this I get a table a,b,c,d,e which e column is all null! I tried to run query for each table before union all to make sure they are not null. I do not really know what is wrong with my query.

Advertisement

Answer

union all does not go by column names. Just list all the columns explicitly:

Regardless of the names you assign, the union all uses positions for matching columns.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement