Need a outer join query for dates

jpaokx

Registered User.
Local time
Today, 11:01
Joined
Sep 23, 2013
Messages
37
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!
 
What I am trying to find is the loss of customers that I have each month compared to its previous populated month

The above can be done easily with just queries. However, your sample data and expected results do not jive and do not help to demonstrate your issue.

Can you better illustrate your issue with better sample data? Please provide 2 sets:

A. Starting sample data from your table(S). Include relevant table and field names and enough data to cover all cases.

B. Expected results. Show me exactly what you want returned when you feed your system the data you provide for A.
 

Users who are viewing this thread

Back
Top Bottom