Ниже приведен пример для BigQuery Standard SQL
#standardSQL
WITH `project.dataset.table` AS (
SELECT 'Email_New_V1' promotion_name, 1 day, 2 month, 2019 year, 3 sent, 2 open, 1 click UNION ALL
SELECT 'Email_New_V2', 1, 2, 2019, 5, 2, 1 UNION ALL
SELECT 'Email_New_V3', 2, 2, 2019, 4, 2, 1 UNION ALL
SELECT 'Email_Old_V1', 1, 2, 2019, 1, 2, 3 UNION ALL
SELECT 'Email_Old_V2', 1, 2, 2019, 4, 5, 6
), promotions AS (
SELECT 'Email_New' promotion_name UNION ALL
SELECT 'Email_Old'
)
SELECT p.promotion_name,
day, month, year,
SUM(sent) sent,
SUM(open) open,
SUM(click) click
FROM `project.dataset.table` t
JOIN promotions p
ON STARTS_WITH(t.promotion_name, p.promotion_name)
GROUP BY promotion_name, day, month, year
с выводом
Row promotion_name day month year sent open click
1 Email_New 1 2 2019 8 4 2
2 Email_New 2 2 2019 4 2 1
3 Email_Old 1 2 2019 5 7 9