Y
Yam84
Hello
I am trying to UNION two queries in hopes to produce the information
that I need.
The Rule: If an employee has an incident, their whole department will
not be eligible to receive leave for 2 months...until the first day of
the 3rd month. If during this time period they transfer to a new
department, they still carry the restriction of their old department.
So if an employee in dept X (who is on probation) transfers to dept Y
in January, that employee, although dept Y is not restricted, they are
still restricted because the dept they came from is on restriction
until April 1st. This is the issue I have been dealing with. Trying
to keep an employee restricted.
The first query determines all employees who were in the department
that has an incident associated with it.
SELECT distinct Q2.empID, Q2.deptID, Q2.empName
FROM Q1 INNER JOIN Q2 ON Q1.deptID = Q2.deptID
WHERE (((Q2.deptID) In (SELECT Q1.DEPTid FROM Q1)));
The next query determines all employees who were in the departments,
including people who have transferred within the two month period. I
am having trouble constructing this query.
Here is my table structure:
Employee: empID, empNo, empName
1, 12345, Thomas Johnson
2, 67890, Tom Mantia,
3, 54321, JohnTest
Dept: deptID, dept
1, Engineering
2, Yard
3, Sandblast
DeptTrans: deptTransID, deptID, empID, transDt, transEndDt
1, 1, 1, 1.1.09, Null
2, 2, 1, 12.1.08, 12.31.08
3, 3, 2, 1.2.09, Null
4, 3, 3, 1.3.09, Null
A Null value in the transEndDt indicates the current department of the
employee
(One employee may have transferred departments many times)
(One employee may be assigned vacation time many times)
VacationTime: vacaID, empID, empEarnedTime, vacaTimeAwardDt
1, 1, 8, 2.1.09
2, 2, 0, Null
3, 3, 4, 2.1.09
(One employee maybe have many incidents)
EmpIncidents: incidentID, empID, incidentTypeID, incidentDt
1, 1, 2, 12.2.08
2, 2, 2, 1.4.09
(One employee can have many types of incidents)
IncidentTypeId: incidentTypeID, incident (the only incidents that
allow an employee and his dept to lose time are types 2 and 3)
1, NonRecordable
2, Recordable
3, Lost-Time
I appreciate any input you can provide.
I am trying to UNION two queries in hopes to produce the information
that I need.
The Rule: If an employee has an incident, their whole department will
not be eligible to receive leave for 2 months...until the first day of
the 3rd month. If during this time period they transfer to a new
department, they still carry the restriction of their old department.
So if an employee in dept X (who is on probation) transfers to dept Y
in January, that employee, although dept Y is not restricted, they are
still restricted because the dept they came from is on restriction
until April 1st. This is the issue I have been dealing with. Trying
to keep an employee restricted.
The first query determines all employees who were in the department
that has an incident associated with it.
SELECT distinct Q2.empID, Q2.deptID, Q2.empName
FROM Q1 INNER JOIN Q2 ON Q1.deptID = Q2.deptID
WHERE (((Q2.deptID) In (SELECT Q1.DEPTid FROM Q1)));
The next query determines all employees who were in the departments,
including people who have transferred within the two month period. I
am having trouble constructing this query.
Here is my table structure:
Employee: empID, empNo, empName
1, 12345, Thomas Johnson
2, 67890, Tom Mantia,
3, 54321, JohnTest
Dept: deptID, dept
1, Engineering
2, Yard
3, Sandblast
DeptTrans: deptTransID, deptID, empID, transDt, transEndDt
1, 1, 1, 1.1.09, Null
2, 2, 1, 12.1.08, 12.31.08
3, 3, 2, 1.2.09, Null
4, 3, 3, 1.3.09, Null
A Null value in the transEndDt indicates the current department of the
employee
(One employee may have transferred departments many times)
(One employee may be assigned vacation time many times)
VacationTime: vacaID, empID, empEarnedTime, vacaTimeAwardDt
1, 1, 8, 2.1.09
2, 2, 0, Null
3, 3, 4, 2.1.09
(One employee maybe have many incidents)
EmpIncidents: incidentID, empID, incidentTypeID, incidentDt
1, 1, 2, 12.2.08
2, 2, 2, 1.4.09
(One employee can have many types of incidents)
IncidentTypeId: incidentTypeID, incident (the only incidents that
allow an employee and his dept to lose time are types 2 and 3)
1, NonRecordable
2, Recordable
3, Lost-Time
I appreciate any input you can provide.