oldteddybear
Registered User.
- Local time
- Today, 08:48
- Joined
- Apr 1, 2012
- Messages
- 12
Can anyone assist please? I cannot seem to get this query to work as I would like.
I have three tables being ServiceStartDate, ServiceEndDate and Service Type.
Clients use the service for periods of time and I need to run a query that identifies what clients have accessed the service and for how long over a specified period of time. I can identify periods of time within the query range however for those that begin prior and run into the time frame and those that run out at the other end I cannot get the query to identify them. To add to this some of the queries that extend past the specific range do not yet have an end date but still need to be caught for the period of time they use the service within the query range.
So I have reduced the query SQL at this point to the following: (I have coloured the text Blue where I feel the problem lies.
SELECT T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
FROM T_ServiceType INNER JOIN (T_OrganisationPickList INNER JOIN (T_EnterClientDemographics INNER JOIN T_Placements ON T_EnterClientDemographics.ClientID = T_Placements.ClientID) ON (T_OrganisationPickList.OrgID = T_Placements.OrgID) AND (T_OrganisationPickList.OrgID = T_EnterClientDemographics.RefOrg)) ON T_ServiceType.ServiceTypeID = T_Placements.ServiceTypeID
GROUP BY T_Placements.ServiceStartDate, T_Placements.ServiceEndDate, T_ServiceType.ServiceType
HAVING (((T_Placements.ServiceStartDate)=IIf([ServiceStartDate]>=[Start Date],[ServiceStartDate],[Start Date])) AND ((T_Placements.ServiceEndDate)=(IIf(([ServiceEndDate])>=[End Date],[End Date],[ServiceEndDate]))) AND ((T_ServiceType.ServiceType)="Standard Placement")) OR (((T_Placements.ServiceStartDate)=IsNull([ServiceStartDate]>=[End Date])) AND ((T_ServiceType.ServiceType)="Standard Placement"));
I have three tables being ServiceStartDate, ServiceEndDate and Service Type.
Clients use the service for periods of time and I need to run a query that identifies what clients have accessed the service and for how long over a specified period of time. I can identify periods of time within the query range however for those that begin prior and run into the time frame and those that run out at the other end I cannot get the query to identify them. To add to this some of the queries that extend past the specific range do not yet have an end date but still need to be caught for the period of time they use the service within the query range.
So I have reduced the query SQL at this point to the following: (I have coloured the text Blue where I feel the problem lies.
SELECT T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
FROM T_ServiceType INNER JOIN (T_OrganisationPickList INNER JOIN (T_EnterClientDemographics INNER JOIN T_Placements ON T_EnterClientDemographics.ClientID = T_Placements.ClientID) ON (T_OrganisationPickList.OrgID = T_Placements.OrgID) AND (T_OrganisationPickList.OrgID = T_EnterClientDemographics.RefOrg)) ON T_ServiceType.ServiceTypeID = T_Placements.ServiceTypeID
GROUP BY T_Placements.ServiceStartDate, T_Placements.ServiceEndDate, T_ServiceType.ServiceType
HAVING (((T_Placements.ServiceStartDate)=IIf([ServiceStartDate]>=[Start Date],[ServiceStartDate],[Start Date])) AND ((T_Placements.ServiceEndDate)=(IIf(([ServiceEndDate])>=[End Date],[End Date],[ServiceEndDate]))) AND ((T_ServiceType.ServiceType)="Standard Placement")) OR (((T_Placements.ServiceStartDate)=IsNull([ServiceStartDate]>=[End Date])) AND ((T_ServiceType.ServiceType)="Standard Placement"));