Hello,
I have a big table with different dates and some customerids.
For example,
date, customerid
01/10/2016, 100001
05/09/2015, 100001
03/06/2013, 100001
01/10/2016, 100002
05/09/2015, 100002
05/09/2015, 100003
03/06/2013, 100004
03/06/2013, 100005
The sequence of dates is random, so there are no consecutive dates. The database is updated once a month on different dates.
What I am trying to find is the loss of customers that I have each month compared to its previous populated month. So, how many were in the previous month but not in the next month.
For example, I want to achieve this one:
date, loss
05/09/2015, 1
03/06/2013, 2
The only way that I can think of is to create temp tables for each populated month and, then, use a outer join query to find this. This can work for just a few months but, for long periods, it is a very long process. However, I need a query so that I can apply for 50-60 different months.
Any thoughts how to achieve this based on the above example?
Thanks guys!
I have a big table with different dates and some customerids.
For example,
date, customerid
01/10/2016, 100001
05/09/2015, 100001
03/06/2013, 100001
01/10/2016, 100002
05/09/2015, 100002
05/09/2015, 100003
03/06/2013, 100004
03/06/2013, 100005
The sequence of dates is random, so there are no consecutive dates. The database is updated once a month on different dates.
What I am trying to find is the loss of customers that I have each month compared to its previous populated month. So, how many were in the previous month but not in the next month.
For example, I want to achieve this one:
date, loss
05/09/2015, 1
03/06/2013, 2
The only way that I can think of is to create temp tables for each populated month and, then, use a outer join query to find this. This can work for just a few months but, for long periods, it is a very long process. However, I need a query so that I can apply for 50-60 different months.
Any thoughts how to achieve this based on the above example?
Thanks guys!