 <p>Something like below<br> I removed WHERE clause and modified rows for d.month and sum(d.spend)<br> Haven't tested, but should be close to working version</p> <pre><code>SELECT d.account_id, d.product, CASE WHEN d.month &gt;= DATE_ADD(CURRENT_DATE() ,-5,"MONTH") THEN d.month ELSE NULL END AS d_month, SUM(CASE WHEN d.month &gt;= DATE_ADD(CURRENT_DATE() ,-5,"MONTH") THEN d.spend ELSE 0 END) AS d_spend, u.lifetime_product_spend FROM FLATTEN(data_source, product) d LEFT JOIN ( SELECT account_id, product, SUM(product_spend)/1000000 lifetime_product_spend FROM usage GROUP BY account_id, product ) u ON (d.account_id = u.account_id AND d.product = u.product) GROUP BY 1, 2, 3, 5 </code></pre>