I have two tables that I'm trying to join clients that go through the process. All clients get to the first step, but only some progress to the second step (table 2). Clients can start this process more than once at different times and can go to the second step in one, one or several months. I would like to know how much to make this progression. Tables as an example:
Table_1
Cust1 1-Jan
Cust2 10-Jan
Cust3 15-Jan
Cust1 2-Feb
Table_2
Cust1 5-Jan
Cust2 16-jan
My request for returning results:
SELECT t1.Cust, t1.Date1, t2.Date2
FROM Table_1 t1
LEFT JOIN Table_2 t2 ON t1.Cust = t2.Cust
WHERE t2.Date is missing OR (t2.Date - t1.Date > 0 AND t2.Date - t1.Date < 10);
This returns:
Cust1 1-Jan 5-Jan
Cust2 10-Jan 16-Jan
Cust3 15-Jan
When I want to return the request:
Cust1 1-Jan 5-Jan
Cust1 2-Feb
Cust2 10-Jan 16-Jan
Cust3 15-Jan
It seems that the request joins Cust1 from February 2 and January 5, and then eliminates this because it does not match the filter. But I need a filter because Cust1 returns in March. How to save the record in February in the final release? Help!