Hi,
Need help writing this query...!
For each calendar year, select all customers who cancelled (as given by a value in the "cancel date" field, otherwise null).
So, for each year, do a count of the "cancel date" (i.e. where "cancel date" is not null). Then I need to divide the yearly cancellation count by the total customer base (as given by the SUM of all customers in the table).
So, it should look something like (but not this):
Select DATEPART(yyyy,canceldate) As 'CancelYear',
count(*) / SUM(SELECT count(*) FROM customers)
from customers
where statusid <= 20
Group by DATEPART(yyyy,canceldate)
order by DATEPART(yyyy,canceldate)
Thanks
Need help writing this query...!
For each calendar year, select all customers who cancelled (as given by a value in the "cancel date" field, otherwise null).
So, for each year, do a count of the "cancel date" (i.e. where "cancel date" is not null). Then I need to divide the yearly cancellation count by the total customer base (as given by the SUM of all customers in the table).
So, it should look something like (but not this):
Select DATEPART(yyyy,canceldate) As 'CancelYear',
count(*) / SUM(SELECT count(*) FROM customers)
from customers
where statusid <= 20
Group by DATEPART(yyyy,canceldate)
order by DATEPART(yyyy,canceldate)
Thanks