Ниже приведен пример для BigQuery Standard SQL
#standardSQL
WITH `project.dataset.data` AS (
SELECT 1 id, '01/01/2014' start_date, '06/01/2014' end_date UNION ALL
SELECT 2, '10/01/2005', '12/01/2015' UNION ALL
SELECT 3, '08/01/2009', '10/01/2012'
), `project.dataset.amounts` AS (
SELECT 1 id, '02/01/2014' month_year, 100 amount UNION ALL
SELECT 1, '03/01/2007', 25 UNION ALL
SELECT 2, '10/01/2010', 50
), all_months AS (
SELECT id, FORMAT_DATE('%m/%d/%Y', month_year) month_year
FROM `project.dataset.data`,
UNNEST(GENERATE_DATE_ARRAY(PARSE_DATE('%m/%d/%Y', start_date), PARSE_DATE('%m/%d/%Y', end_date), INTERVAL 1 MONTH)) month_year
)
SELECT id, month_year, SUM(IFNULL(amount, 0)) amount
FROM all_months m
LEFT JOIN `project.dataset.amounts` a
USING (id, month_year)
GROUP BY id, month_year