Getting runtime error? Works fine on mysql 5.5


  • 1
    C

    Why am I getting a runtime error?

    It works fine on my machine running 5.5

    set @last := '';
    set @cnter := 1;
    select 
        d.Name as Department,
        j.Employee as Employee,
        j.Salary as Salary
    from
        (select 
            e.Name as Employee,
                e.Salary as Salary,
                e.DepartmentId as DepartmentId,
                if(@last <> e.DepartmentId, @cnter:=1, @cnter:=@cnter + 1) as rank,
                @last:=e.DepartmentId
        from
            Employee e
        order by e.DepartmentId , e.Salary desc) j
            left join
        Department d ON (j.DepartmentId = d.Id)
    where
        rank <= 3;

Log in to reply
 

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