SELECT
  submission_date,
  search_engine,
  search_access_point,
  pocket_story_position,
  default_private_search_engine,
  default_search_engine,
  os,
  os_version,
  country_code,
  channel,
  browser_version,
  browser_name,
  newtab_open_source,
  pocket_is_signed_in,
  pocket_enabled,
  pocket_sponsored_stories_enabled,
  topsites_enabled,
  newtab_homepage_category,
  newtab_newtab_category,
  newtab_search_enabled,
  topsites_rows,
  is_new_profile,
  activity_segment,
  COUNT(DISTINCT client_id) AS client_count,
  COUNT(DISTINCT legacy_telemetry_client_id) AS legacy_telemetry_client_count,
  COUNT(DISTINCT newtab_visit_id) AS newtab_interactions_visits,
        -- Topsite
  SUM(topsite_clicks) AS topsite_clicks,
  SUM(sponsored_topsite_clicks) AS sponsored_topsite_clicks,
  SUM(organic_topsite_clicks) AS organic_topsite_clicks,
  SUM(topsite_impressions) AS topsite_impressions,
  SUM(sponsored_topsite_impressions) AS sponsored_topsite_impressions,
  SUM(organic_topsite_impressions) AS organic_topsite_impressions,
  SUM(topsite_dismissals) AS topsite_dismissals,
  SUM(sponsored_topsite_dismissals) AS sponsored_topsite_dismissals,
  SUM(organic_topsite_dismissals) AS organic_topsite_dismissals,
        -- Search
  SUM(searches) AS searches,
  SUM(tagged_search_ad_clicks) AS tagged_search_ad_clicks,
  SUM(tagged_search_ad_impressions) AS tagged_search_ad_impressions,
  SUM(follow_on_search_ad_clicks) AS follow_on_search_ad_clicks,
  SUM(follow_on_search_ad_impressions) AS follow_on_search_ad_impressions,
  SUM(tagged_follow_on_search_ad_clicks) AS tagged_follow_on_search_ad_clicks,
  SUM(tagged_follow_on_search_ad_impressions) AS tagged_follow_on_search_ad_impressions,
        -- Pocket
  SUM(pocket_impressions) AS pocket_impressions,
  SUM(sponsored_pocket_impressions) AS sponsored_pocket_impressions,
  SUM(organic_pocket_impressions) AS organic_pocket_impressions,
  SUM(pocket_clicks) AS pocket_clicks,
  SUM(sponsored_pocket_clicks) AS sponsored_pocket_clicks,
  SUM(organic_pocket_clicks) AS organic_pocket_clicks,
  SUM(pocket_saves) AS pocket_saves,
  SUM(sponsored_pocket_saves) AS sponsored_pocket_saves,
  SUM(organic_pocket_saves) AS organic_pocket_saves,
FROM
  `moz-fx-data-shared-prod.telemetry_derived.newtab_interactions_v1`
WHERE
  submission_date = @submission_date
GROUP BY
  submission_date,
  search_engine,
  search_access_point,
  pocket_story_position,
  default_private_search_engine,
  default_search_engine,
  os,
  os_version,
  country_code,
  channel,
  browser_version,
  browser_name,
  newtab_open_source,
  pocket_is_signed_in,
  pocket_enabled,
  pocket_sponsored_stories_enabled,
  topsites_enabled,
  newtab_homepage_category,
  newtab_newtab_category,
  newtab_search_enabled,
  topsites_rows,
  is_new_profile,
  activity_segment
