sql - Combine multiple SELECT FROM on both intraday and app_events tables in BigQuery? -
is there way can combine both of these select statements one? i've tried doing:
from
dataset1.app_events_intraday_*,dataset2.app_events_*, unnest (event_dim) event
when run column name event_dim ambiguous i'm not sure why be. how run query on both of these tables without having run 2 unions?
here full query interested:
with alltables ( select concat(user_dim.app_info.app_instance_id, ':', user_dim.app_info.app_platform) app, event.date, user_dim.app_info.app_instance_id users `dataset1.app_events_intraday_*`, unnest(event_dim) event _table_suffix between '20170405' , '20170405' union select concat(user_dim.app_info.app_instance_id, ':', user_dim.app_info.app_platform) app, event.date, user_dim.app_info.app_instance_id users `dataset2.app_events_*`, unnest(event_dim) event _table_suffix between '20170405' , '20170405' ) select count(distinct(users)) unique, count(users) total alltables
from dataset1.app_events_intraday_, dataset2.app_events_, unnest (event_dim) event
when run column name event_dim ambiguous i'm not sure why
event_dim ambiguous because filed exists in both app_events_intraday_* , app_events_* tables
how run query on both of these tables without having run 2 unions?
if have both sets of tables in same dataset - able adjust from
from dataset.app_events_*, unnest (event_dim) event such dataset.app_events_* pattern cover both sets
in case, though, need adjust clause below
where substr(_table_suffix, -8) between '20170405' , '20170405' now - bad news
wildcard limited tables in same dataset!
in case cannot eliminate use of union
Comments
Post a Comment