asullivan62
asked on
Max rehire date for employee in a case statement
I NEED a case statement that returns the max rehire date when the condition = 101.
here is the original case statement:
case when eec.EecJobChangeReason = '100' then CONVERT(VARCHAR(25),eec.Ee cDateOfOri ginalHire, 101)
when eec.EecJobChangeReason <> '101' then CONVERT(VARCHAR(25),eec.ee cdateoflas thire, 101)
end AS 'Hire Date',
case when eec.EecJobChangeReason = '101' then CONVERT(VARCHAR(25),eec.ee cdateoflas thire , 101)
end as 'ReHire-Date',
CONVERT(VARCHAR(25), eec.EecDateOfSeniority, 101) AS 'Seniority Date',
******I need this part of the case statement to return the max rehire date for that employee**************
case when eec.EecJobChangeReason = '101' then CONVERT(VARCHAR(25),eec.ee cdateoflas thire , 101)
end as 'ReHire-Date',
here is the original case statement:
case when eec.EecJobChangeReason = '100' then CONVERT(VARCHAR(25),eec.Ee
when eec.EecJobChangeReason <> '101' then CONVERT(VARCHAR(25),eec.ee
end AS 'Hire Date',
case when eec.EecJobChangeReason = '101' then CONVERT(VARCHAR(25),eec.ee
end as 'ReHire-Date',
CONVERT(VARCHAR(25), eec.EecDateOfSeniority, 101) AS 'Seniority Date',
******I need this part of the case statement to return the max rehire date for that employee**************
case when eec.EecJobChangeReason = '101' then CONVERT(VARCHAR(25),eec.ee
end as 'ReHire-Date',
if you need the "max" rehire date, you need to apply MAX() around the case expression (and put the relevant GROUP BY to your sql also, of course.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.