Агрегируйте дважды. Следующее разбивает вещи на счет домашней страницы и поиска:
select ds, num_homepage, num_search, count(*) as num_users
from (select user_id,
cast(date_parse(substr(sessions.datehour, 1, 8),'%Y%m%d') as date) as ds
sum(case when entrypoint = 'homepage' then 1 else 0 end) as num_Homepage,
sum(case when entrypoint = 'search' then 1 else 0 end) as num_search
from bizinsights.events_entrypoints_clientevents
where eventtype = 'Click' and
cast(date_parse(substr(sessions.datehour, 1, 8),'%Y%m%d') as date) >= '2020-01-01'
group by user_id, ds
) u
group by ds, num_homepage, num_search
order by ds, num_homepage, num_search;
Это больше, чем вы просите. Вместо:
select ds,
count_if(is_Homepage = 1 and is_Search = 1) as both,
count_if(is_Homepage = 1 and is_Search = 0) as homepage_only,
count_if(is_Homepage = 1 and is_Search = 1) as search_only
from (select user_id,
cast(date_parse(substr(sessions.datehour, 1, 8),'%Y%m%d') as date) as ds
max(case when entrypoint = 'homepage' then 1 else 0 end) as is_Homepage,
max(case when entrypoint = 'search' then 1 else 0 end) as is_search
from bizinsights.events_entrypoints_clientevents
where eventtype = 'Click' and
cast(date_parse(substr(sessions.datehour, 1, 8),'%Y%m%d') as date) >= '2020-01-01'
group by user_id, ds
) u
group by ds
order by ds;