Link to home
Start Free TrialLog in
Avatar of asullivan62
asullivan62Flag for United States of America

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.EecDateOfOriginalHire, 101)
             when eec.EecJobChangeReason  <> '101' then CONVERT(VARCHAR(25),eec.eecdateoflasthire, 101)
             end AS 'Hire Date',
            case when eec.EecJobChangeReason  = '101' then CONVERT(VARCHAR(25),eec.eecdateoflasthire      , 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.eecdateoflasthire      , 101)
            end as 'ReHire-Date',
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial