Potenial Solution


  • 0
    S

    select E.Id, E.Month, (select sum(Salary) from Employee as ECS where ECS.Id = E.ID and ECS.Month <= E.Month) as Salary
    from Employee as E
    join
    (select Id, max(Month) as M_Month
    from Employee as E
    group by Id) as ES on E.Id = ES.ID
    where E.Month != ES.M_Month
    order by Id, Salary desc

    I cross checked my answer with the given dataset but it's not accepted. The expected output seems to be wrong for the Id 1.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.