Question : Records In 14 days Date Range

I have three tables Client , Client_Current_Status, Client_All_Statuses

Table Client has next fields:
Client_ID,Client_Name,Client_Phone

Table Client_Current_Status has next fields:
Status_Id,Client_Id,Status_Code,Start_Date,End_Date

Client_All_Statuses has next fields:
Status_Id,Status_Code,Start_Date,End_Date


Next data in Client table:
Client_ID is Pk.

Client_ID      Client_Name            Client_Phone            
11111      John Peterson      416-444-3455            
22222      Tom Jonson            416-555-5544            
33333      Mary Smith            416-321-4567             
44444      Raji  Junny            416-333-4575
             

Next data in Client_Current_Status table:
Status_ID is Pk

Status_ID      Client_ID       Status_Code      Date_Start      Date_End      
123AAA      11111      Open      01/01/2010      Null      
124BBB      22222      Closed      01/05/2010      01/20/2010
125CCC      33333      Closed      02/02/2010      03/10/2010
126DDD      44444      Open      03/01/2010      Null


Next data in Client_All_Statuses table:

Status_ID      Status_Code        Start_Date         End_Date
123AAA      Closed        10/01/2009         10/05/2009
123AAA      Closed        10/10/2009         11/01/2009
123AAA      Closed        11/03/2009         12/01/2009
123AAA      Open        01/01/2010         Null
124BBB      Closed        10/06/2009         11/05/2009
124BBB      Closed        01/05/2010         01/20/2010
125CCC      Closed        01/10/2010         01/20/2010
125CCC      Closed        02/02/2010         03/10/2010
126DDD      Open        03/01/2010         Null

I need to pull clients with Status_ID that has Status_Code re-opend  in 14 days range.
It means 14 days or less passed between End_Date and next Start_Date for Status_Code.
It means those clients has to have at least 2 entries in Client_All_Statuses table
To be qualified.
44444 has just one and is not counted.



Result has to be something as this.

Client_ID      Status_ID      Re_Opened_Code<14Days
11111      123AAA            Yes
33333      125CCC            Yes

I need select statement that will give me this result.
In need to run it against SQL Server2008.

Answer : Records In 14 days Date Range

I am using Access 2003 and it does indeed have an "On Change" event. ??????
Random Solutions  
 
programming4us programming4us