Vote count:
0
I am working with several tables. An Employee table (tblEmployee), a Managers table (tblManager), and a manager log table (tblLog). In the log table there is about 10 columns. The first column is the manager ID. There is another column that has the first name of an employee to be transferred, and to which dept that employee should go to. Below is a snapshot of that column:
Bob- Dept: 7 Meg- Dept: 5
Bob- Dept: 7 Meg- Dept: 5
Bob- Dept: 7 Meg- Dept: 5
Preston- Dept: 1
Martin- Dept: MANG Sue- Dept: MANG Sarah - DEPT: 8
Martin- Dept: MANG Sue- Dept: MANG Sarah - DEPT: 8
Martin- Dept: MANG Sue- Dept: MANG Sarah - DEPT: 8
Isabel- Dept: 6 Mike- Dept: 5
Isabel- Dept: 6 Mike- Dept: 5
Dan- Dept: MANG
Dan- Dept: MANG
As you can see, there are duplicate rows. The manager who is recommending Bob and Meg be transferred has 3 rows for his ID. That is because he has 3 employees in the table, a row for each employee. I am working on extracting just the employees that are being transferred to management (MANG) or another dept(#1-8). I have a query written that gets all of the information I need, but it gets every employee in the log table, it currently does not filter out the extra ones. So say I am returning 150 rows, there are actually only 100 employee tranfers and 50 other employees who are in the log table for a different reason.
I was trying to come up with a query that takes the first name of the employee and checks if it is in the column, then takes the employees future dept number (from tblEmployee) and checks that it matches the number in the log column. I have looked at PARTINDEX
and REGEXs but I am not skilled enough to come up with a solution that can achieve the desired result
Aucun commentaire:
Enregistrer un commentaire