J
jubu
I have 3 tables in my database (With sample info. Actually there are more,
but these are the ones giving me grief.). tblClientcountyInfo keeps track of
county info and when it changes. tblEmploy keeps track of when they begin
employment and where. tblEmpRetention stores information on the employment
retention information.
tblClientCountyInfo
RecordID StaffNo County DateRevised
1 471591 Ottawa 3/26/08
2 534341 Muskegon 9/25/07
3 534341 Ottawa 4/9/08
4 471591 Muskegon 7/14/08
tblEmploy
RecordID StaffNo EmployerName EmployStartDate
70 471591 Tri-State 4/1/08
90 534341 ABC Company 4/23/08
tblEmpRetention
id EmployRecordID StaffNo Type AsOfDate
67 70 471591 Placement 4/1/08
87 90 534341 Placement 4/23/08
154 70 471591 30-Day 5/1/08
172 90 534341 30-Day 5/23/08
231 70 471591 60-Day 5/31/08
249 90 534341 60-Day 6/22/08
293 70 471591 90-Day 6/30/08
311 90 534341 90-Day 7/22/08
This is the SQL of the query and the results are shown below in the table.
Here’s my problem: I do NOT want any records to appear, if they do not fall
between the dates correctly. Please look at the records for Staff No 534341.
I do not want to see the records where Date Revised are 9/25/07, because
their EmployStartDate was on or after the second record for this person
4/9/08.
SELECT tblClientCountyInfo.StaffNo, tblClientCountyInfo.County,
tblClientCountyInfo.DateRevised, tblEmploy.EmployerName,
tblEmploy.EmployStartDate, tblEmpRetention.Type, tblEmpRetention.AsOfDate,
IIf([asofdate]<[DateRevised],"",[Asofdate]) AS ValidDates
FROM (tblClientCountyInfo INNER JOIN tblEmploy ON
tblClientCountyInfo.StaffNo = tblEmploy.StaffNo) INNER JOIN tblEmpRetention
ON tblEmploy.RecordID = tblEmpRetention.EmployRecordID
ORDER BY tblClientCountyInfo.StaffNo, tblClientCountyInfo.DateRevised,
tblEmpRetention.AsOfDate;
qryPlacementRetentionInfo-
StaffNo County DateRevised EmployerName EmployStartDate Type AsOfDate ValidDates
471591 Ottawa 3/26/08 Tri-State 4/1/08 Placement 4/1/08 4/1/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 30-Day 5/1/08 5/1/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 60-Day 5/31/08 5/31/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 90-Day 6/30/08 6/30/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 Placement 4/1/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 30-Day 5/1/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 60-Day 5/31/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 90-Day 6/30/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 Placement 4/23/08 4/23/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 30-Day 5/23/08 5/23/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 60-Day 6/22/08 6/22/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 90-Day 7/22/08 7/22/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 Placement 4/23/08 4/23/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 30-Day 5/23/08 5/23/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 60-Day 6/22/08 6/22/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 90-Day 7/22/08 7/22/08
thanks in advance for any suggestions.
but these are the ones giving me grief.). tblClientcountyInfo keeps track of
county info and when it changes. tblEmploy keeps track of when they begin
employment and where. tblEmpRetention stores information on the employment
retention information.
tblClientCountyInfo
RecordID StaffNo County DateRevised
1 471591 Ottawa 3/26/08
2 534341 Muskegon 9/25/07
3 534341 Ottawa 4/9/08
4 471591 Muskegon 7/14/08
tblEmploy
RecordID StaffNo EmployerName EmployStartDate
70 471591 Tri-State 4/1/08
90 534341 ABC Company 4/23/08
tblEmpRetention
id EmployRecordID StaffNo Type AsOfDate
67 70 471591 Placement 4/1/08
87 90 534341 Placement 4/23/08
154 70 471591 30-Day 5/1/08
172 90 534341 30-Day 5/23/08
231 70 471591 60-Day 5/31/08
249 90 534341 60-Day 6/22/08
293 70 471591 90-Day 6/30/08
311 90 534341 90-Day 7/22/08
This is the SQL of the query and the results are shown below in the table.
Here’s my problem: I do NOT want any records to appear, if they do not fall
between the dates correctly. Please look at the records for Staff No 534341.
I do not want to see the records where Date Revised are 9/25/07, because
their EmployStartDate was on or after the second record for this person
4/9/08.
SELECT tblClientCountyInfo.StaffNo, tblClientCountyInfo.County,
tblClientCountyInfo.DateRevised, tblEmploy.EmployerName,
tblEmploy.EmployStartDate, tblEmpRetention.Type, tblEmpRetention.AsOfDate,
IIf([asofdate]<[DateRevised],"",[Asofdate]) AS ValidDates
FROM (tblClientCountyInfo INNER JOIN tblEmploy ON
tblClientCountyInfo.StaffNo = tblEmploy.StaffNo) INNER JOIN tblEmpRetention
ON tblEmploy.RecordID = tblEmpRetention.EmployRecordID
ORDER BY tblClientCountyInfo.StaffNo, tblClientCountyInfo.DateRevised,
tblEmpRetention.AsOfDate;
qryPlacementRetentionInfo-
StaffNo County DateRevised EmployerName EmployStartDate Type AsOfDate ValidDates
471591 Ottawa 3/26/08 Tri-State 4/1/08 Placement 4/1/08 4/1/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 30-Day 5/1/08 5/1/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 60-Day 5/31/08 5/31/08
471591 Ottawa 3/26/08 Tri-State 4/1/08 90-Day 6/30/08 6/30/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 Placement 4/1/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 30-Day 5/1/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 60-Day 5/31/08
471591 Muskegon 7/14/08 Tri-State 4/1/08 90-Day 6/30/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 Placement 4/23/08 4/23/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 30-Day 5/23/08 5/23/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 60-Day 6/22/08 6/22/08
534341 Muskegon 9/25/07 ABC Company 4/23/08 90-Day 7/22/08 7/22/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 Placement 4/23/08 4/23/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 30-Day 5/23/08 5/23/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 60-Day 6/22/08 6/22/08
534341 Ottawa 4/9/08 ABC Company 4/23/08 90-Day 7/22/08 7/22/08
thanks in advance for any suggestions.