Skip to content

Instantly share code, notes, and snippets.

@MGCodesandStats
Created July 24, 2022 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MGCodesandStats/42a3fdbecadb4c946e9f5c644c30b624 to your computer and use it in GitHub Desktop.
Save MGCodesandStats/42a3fdbecadb4c946e9f5c644c30b624 to your computer and use it in GitHub Desktop.
Average postpaid churn rates for Rogers Communications and Bell Canada.
telecoms=# select year, cast(avg(churn) as decimal(4,2)) as churn from canada_telecoms where company='Rogers' group by year order by year;
year | churn
------+-------
2019 | 1.11
2020 | 1.00
2021 | 0.95
2022 | 0.71
(4 rows)
telecoms=# select year, cast(avg(churn) as decimal(4,2)) as churn from canada_telecoms where company='Bell' group by year order by year;
year | churn
------+-------
2019 | 1.13
2020 | 0.99
2021 | 0.93
2022 | 0.79
(4 rows)
# Original Data
telecoms=# select * from canada_telecoms where company='Rogers' order by year, quarter;
year | quarter | churn | company
------+---------+-------+---------
2019 | Q1 | 0.99 | Rogers
2019 | Q2 | 0.99 | Rogers
2019 | Q3 | 1.20 | Rogers
2019 | Q4 | 1.26 | Rogers
2020 | Q1 | 0.93 | Rogers
2020 | Q2 | 0.77 | Rogers
2020 | Q3 | 1.10 | Rogers
2020 | Q4 | 1.19 | Rogers
2021 | Q1 | 0.88 | Rogers
2021 | Q2 | 0.80 | Rogers
2021 | Q3 | 0.95 | Rogers
2021 | Q4 | 1.15 | Rogers
2022 | Q1 | 0.71 | Rogers
telecoms=# select * from canada_telecoms where company='Bell' order by year, quarter;
year | quarter | churn | company
------+---------+-------+---------
2019 | Q1 | 1.07 | Bell
2019 | Q2 | 1.06 | Bell
2019 | Q3 | 1.12 | Bell
2019 | Q4 | 1.28 | Bell
2020 | Q1 | 0.97 | Bell
2020 | Q2 | 0.82 | Bell
2020 | Q3 | 1.04 | Bell
2020 | Q4 | 1.11 | Bell
2021 | Q1 | 0.89 | Bell
2021 | Q2 | 0.83 | Bell
2021 | Q3 | 0.93 | Bell
2021 | Q4 | 1.08 | Bell
2022 | Q1 | 0.79 | Bell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment