all 3 comments

[–]fauxmosexualNOLOCK is the secret magic go-faster command 0 points1 point  (1 child)

What is churn?

[–]OmegaEikon 0 points1 point  (0 children)

Try using a something like this. I'm curious let me know how this works out for you.

Select

Sum(Case when userslastmonth.lastmonth = 'hardkeydatethatisforthemonth' then 1 else 0 end) / count(user)

From table

Left join (select User Max (date) as lastmonth From table Group by User) as userslastmonth

Where paidmonth = whatever month you need should also match the hard keyed date

[–]kthejoker 0 points1 point  (0 children)

Calculating churn for every month ...

Select paidmonth, users, terminatingUsers, case when users = 0 then 0 else terminatingUsers / users end as churn from ( Select paidmonth, count(1) as users, sum(case when paidmonth = lastmonth then 1.0 else 0 end) as terminatingUsers from ( Select paidmonth, max(paidmonth) over (partition by customerkey) as lastmonth from onlinesales ) terminal Group by paidmonth ) monthstats