I need a sql statement that shows-the child's session information(ex. date, time started, time ended), therapists info(ex. name, id), and child's info (ex. id,name, dob)
But to make it tougher-I need all the sessions per child-with the specified child, and therapist-but the query should display -all the child's sessions-for the day that the specified therapist saw the child (but should include all the sessions-including other therapist's session-for that day, that child)
ex. if therapist A saw child Z on 1/1/03 (and therapist B,D,& F saw child Z on 1/1/03 too) then the query should display all 4 session for therapist a,b,d,& f)
This is the code to get the specific therapist and child-but not the other therapists info:
sql = "SELECT Sessions.UserName, Sessions.OSIS, Sessions.WereServiceRendered, Sessions.ServiceType, Sessions.ErrorCodes, Sessions.DateOfService, Sessions.TimeSessionStarted,Sessions.TimeSessionEnded, Sessions.TotalSessionDuration, Students.[Last Name], Students.[First Name], Students.[Date of Birth], Employees.[LAST NAME], Employees.[FIRST NAME], Employees.[Employee ID] FROM (Sessions INNER JOIN Students ON Sessions.OSIS = Students.[Student ID]) INNER JOIN Employees ON Sessions.EmployeeID = Employees.[Employee ID] WHERE (((Sessions.DateOfService)>= #" & BeginDate & "#) AND ((Sessions.DateOfService) <= #" & EndDate & "#)) "
sql = sql & " GROUP BY Sessions.UserName, Sessions.OSIS, Sessions.WereServiceRendered, Sessions.ServiceType, Sessions.DateOfService, Sessions.TimeSessionStarted,Sessions.TimeSessionEnded, Sessions.TotalSessionDuration,Students.[Last Name], Students.[First Name], Students.[Date of Birth], Employees.[LAST NAME], Employees.[FIRST NAME], Employees.[Employee ID], Sessions.ErrorCodes HAVING ( ((Sessions.WereServiceRendered)='y') AND (Sessions.ErrorCodes Is Null Or Sessions.ErrorCodes <>'del') ) "
if StudentId <> "" then sql = sql & " and Sessions.OSIS = '" & StudentId & "'"
sql = sql & " and Employees.[Employee ID] =" & Session("EmpID" & " order by Sessions.DateOfService, Sessions.TimeSessionStarted "%>
Any Help would be appreciated.
But to make it tougher-I need all the sessions per child-with the specified child, and therapist-but the query should display -all the child's sessions-for the day that the specified therapist saw the child (but should include all the sessions-including other therapist's session-for that day, that child)
ex. if therapist A saw child Z on 1/1/03 (and therapist B,D,& F saw child Z on 1/1/03 too) then the query should display all 4 session for therapist a,b,d,& f)
This is the code to get the specific therapist and child-but not the other therapists info:
sql = "SELECT Sessions.UserName, Sessions.OSIS, Sessions.WereServiceRendered, Sessions.ServiceType, Sessions.ErrorCodes, Sessions.DateOfService, Sessions.TimeSessionStarted,Sessions.TimeSessionEnded, Sessions.TotalSessionDuration, Students.[Last Name], Students.[First Name], Students.[Date of Birth], Employees.[LAST NAME], Employees.[FIRST NAME], Employees.[Employee ID] FROM (Sessions INNER JOIN Students ON Sessions.OSIS = Students.[Student ID]) INNER JOIN Employees ON Sessions.EmployeeID = Employees.[Employee ID] WHERE (((Sessions.DateOfService)>= #" & BeginDate & "#) AND ((Sessions.DateOfService) <= #" & EndDate & "#)) "
sql = sql & " GROUP BY Sessions.UserName, Sessions.OSIS, Sessions.WereServiceRendered, Sessions.ServiceType, Sessions.DateOfService, Sessions.TimeSessionStarted,Sessions.TimeSessionEnded, Sessions.TotalSessionDuration,Students.[Last Name], Students.[First Name], Students.[Date of Birth], Employees.[LAST NAME], Employees.[FIRST NAME], Employees.[Employee ID], Sessions.ErrorCodes HAVING ( ((Sessions.WereServiceRendered)='y') AND (Sessions.ErrorCodes Is Null Or Sessions.ErrorCodes <>'del') ) "
if StudentId <> "" then sql = sql & " and Sessions.OSIS = '" & StudentId & "'"
sql = sql & " and Employees.[Employee ID] =" & Session("EmpID" & " order by Sessions.DateOfService, Sessions.TimeSessionStarted "%>
Any Help would be appreciated.