gRegulator
Technical User
Hi,
I have been using the following SQL code to find the average number of clients that are supervised over a selected time period. It works great. The date fields that it uses are [Probation Start] and [Probation Expiry].
What I am looking to do is a similar objective, except this time I would like to calculate the number of people who have a Community Service requirement. The problem that I encounter is that the start and end dates for the Community Service may come from either [Probation Start] and [Probation End] OR [CS Start] and [CS End]. If the client has a community service requirement, then the check box [Community Service Order] in tbl_offenders will be checked as yes.
I hope this makes sense to everyone and I truly appreciate any help that you may have!
Thanks!
I have been using the following SQL code to find the average number of clients that are supervised over a selected time period. It works great. The date fields that it uses are [Probation Start] and [Probation Expiry].
Code:
PARAMETERS [Forms]![frm_Table5_AverageCount]![txtStart] DateTime, [Forms]![frm_Table5_AverageCount]![txtEnd] DateTime;
SELECT MALE, FEMALE, Sum(IIf([Probation Expiry]>[Forms]![frm_Table5_AverageCount]![txtEnd],[Forms]![frm_Table5_AverageCount]![txtEnd],[Probation Expiry])-IIf([Probation Start]<[Forms]![frm_Table5_AverageCount]![txtStart],[Forms]![frm_Table5_AverageCount]![txtStart],[Probation Start]))/([Forms]![frm_Table5_AverageCount]![txtEnd]-[Forms]![frm_Table5_AverageCount]![txtStart]) AS [Average Daily Count of Adult Offenders on Supervised Probation]
FROM tbl_offenders
WHERE (((tbl_offenders.[Probation Expiry])>=[Forms]![frm_Table5_AverageCount]![txtStart]) AND ((tbl_offenders.[Probation Start])<=[Forms]![frm_Table5_AverageCount]![txtEnd]))
GROUP BY MALE, FEMALE;
What I am looking to do is a similar objective, except this time I would like to calculate the number of people who have a Community Service requirement. The problem that I encounter is that the start and end dates for the Community Service may come from either [Probation Start] and [Probation End] OR [CS Start] and [CS End]. If the client has a community service requirement, then the check box [Community Service Order] in tbl_offenders will be checked as yes.
I hope this makes sense to everyone and I truly appreciate any help that you may have!
Thanks!