Hello:
I am trying to put together a query that determines employees who are in a department that has had an incident with in the last two months. I have a query that determines who has had and incident and the department they were in when they had the incident:
I believe i need to use this query in conjunction with another query to match anyone in a department from above to all other employees in that department, so I may penalize that department as a whole. I have a query that tells me all employed currently and their current department, but I used that one in the above query to get my record set. How can I find other employees with in the department of the offending employees?
I am trying to put together a query that determines employees who are in a department that has had an incident with in the last two months. I have a query that determines who has had and incident and the department they were in when they had the incident:
Code:
SELECT Q_RestrictedEmployees.empID, Q_RestrictedEmployees.empNo, Q_RestrictedEmployees.empName, Q_RestrictedEmployees.incidentDt, Q_RestrictedEmployees.RestrictionEnd, (Select top 1 dept from Q_DeptTrans where Q_DeptTrans.empID=Q_RestrictedEmployees.empID and Q_DeptTrans.depttransDt<=Q_RestrictedEmployees.incidentDt) AS Dept_At_Time_Of_Incident FROM Q_CurrentDepts INNER JOIN Q_RestrictedEmployees ON Q_CurrentDepts.empID = Q_RestrictedEmployees.empID;
Comment