G
Guest
SELECT E.BranchID, Branch_TBL.Branch_Desc, Branch_TBL.BranchCategory,
Count(E.BranchID) AS CountOfBranchID, E.EffectiveDate, E1.EmployeeID,
E.Action_Abrv, E.Status, E.EffectiveSequence
FROM Branch_TBL INNER JOIN
(
History_Internal_Employment AS E INNER JOIN
(SELECT EmployeeID, Max(EffectiveDate) as MaxDate
FROM History_Internal_Employment
WHERE EffectiveDate <= [Enter Date]
GROUP BY EmployeeID) AS E1 ON
(E.EffectiveDate = E1.MaxDate) AND (E.EmployeeID = E1.EmployeeID)
)
ON Branch_TBL.BranchID = E.BranchID
WHERE (((E.Status)="Active") AND ((E.EffectiveSequence)=(SELECT
Max(E.EffectiveSequence) FROM History_Internal_Employment WHERE
E.EmployeeID=E1.EmployeeID )))
GROUP BY E.BranchID, Branch_TBL.Branch_Desc, Branch_TBL.BranchCategory,
E.EffectiveDate, E1.EmployeeID, E.Action_Abrv, E.Status, E.EffectiveSequence;
Hi these are the codes to extract a certain data. It does the following
1)Take those effective dates <= [Date Prompt]
2)Take maximum effective date
3)Did a JOIN from Branch_TBL.branchID with History Data BranchID
4) Only select those whose Status are Active
The problem is...
there's a record that has 2 event happen in 1 day, and it show up as 2
records.
For example in sequence:ID,Name,BranchID,EffectiveDate,EffectiveSequence,
0001 Mr A 3201 1-8-2000 0
0001 Mr A 3201 1-8-2000 2
I have problems fixing in the query and trying to put in the effective
sequence but it fails... Have tried for around a week but just give up. I
just need to adjust the codes in such a way that out of the two record in the
example, the results only show the max EffectiveSequence
Your help is deeply appreciated.
Count(E.BranchID) AS CountOfBranchID, E.EffectiveDate, E1.EmployeeID,
E.Action_Abrv, E.Status, E.EffectiveSequence
FROM Branch_TBL INNER JOIN
(
History_Internal_Employment AS E INNER JOIN
(SELECT EmployeeID, Max(EffectiveDate) as MaxDate
FROM History_Internal_Employment
WHERE EffectiveDate <= [Enter Date]
GROUP BY EmployeeID) AS E1 ON
(E.EffectiveDate = E1.MaxDate) AND (E.EmployeeID = E1.EmployeeID)
)
ON Branch_TBL.BranchID = E.BranchID
WHERE (((E.Status)="Active") AND ((E.EffectiveSequence)=(SELECT
Max(E.EffectiveSequence) FROM History_Internal_Employment WHERE
E.EmployeeID=E1.EmployeeID )))
GROUP BY E.BranchID, Branch_TBL.Branch_Desc, Branch_TBL.BranchCategory,
E.EffectiveDate, E1.EmployeeID, E.Action_Abrv, E.Status, E.EffectiveSequence;
Hi these are the codes to extract a certain data. It does the following
1)Take those effective dates <= [Date Prompt]
2)Take maximum effective date
3)Did a JOIN from Branch_TBL.branchID with History Data BranchID
4) Only select those whose Status are Active
The problem is...
there's a record that has 2 event happen in 1 day, and it show up as 2
records.
For example in sequence:ID,Name,BranchID,EffectiveDate,EffectiveSequence,
0001 Mr A 3201 1-8-2000 0
0001 Mr A 3201 1-8-2000 2
I have problems fixing in the query and trying to put in the effective
sequence but it fails... Have tried for around a week but just give up. I
just need to adjust the codes in such a way that out of the two record in the
example, the results only show the max EffectiveSequence
Your help is deeply appreciated.