Cumulative line chart
Building cumulative line charts: Tracking growth and trends over time
SQL code to transform the data for creating a cumulative line chart
/* to display the cumulative number of unique campaigns per month and country */
select a.*, c.Cumulative_Campaigns from Table_Name a
left join
(select b.*, SUM(b.Unique_Campaigns) over ( partition by b.Country order by b.Month ) as Cumulative_Campaigns from
( select Month , Country , count(distinct Email_campaign_name ) as Unique_Campaigns
from Table_Name group by Month , Country ) b
) c
on a.Month = c.Month and a.Country = c.CountryFirst subquery (b)
Second subquery with window function (c)
Outer query
Was this helpful?